The app keeps crashing i have been trying trying many times searching online but i still cant get it
Do anyone know what is the cause of the app keep crashing? Im new to this got school assignment.
Can i copy a code from another file which have a different domain and paste it to other file with different domain?
How can i copy a file from a different domain and paste to another file
Logcat
FATAL EXCEPTION: main
Process: sp.com, PID: 31720
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{sp.com/sp.com.DetailsFragment}: java.lang.ClassCastException: sp.com.DetailsFragment cannot be cast to android.app.Activity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassCastException: sp.com.DetailsFragment cannot be cast to android.app.Activity
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.P2120287Assignment">
<activity
android:name=".DetailsFragment"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".SplashScreen"
android:exported="true"
android:theme="#style/SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In the manifest file you are referencing a Fragment inside an activity tag:
<activity
android:name=".DetailsFragment"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
This is not possible. You need to reference an Activity here.
Related
I am making an app that runs login_nb first. There was not problem until I added userinfoinput.kt to this project, but it made some errors after that.
My code manifest code is :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.nb_main">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Nb_main"
android:usesCleartextTraffic="true">
<activity android:name=".SignUp" />
<activity android:name=".photoboard" />
<activity android:name=".addPhoto" />
<activity android:name=".textboard" />
<activity android:name=".login_nb">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <!-- Move this to set the initial activity -->
<category android:name="android.intent.category.LAUNCHER" /> <!-- Move this to set the initial activity -->
</intent-filter>
</activity>
<activity android:name=".popup_color" />
<activity android:name=".built" />
<activity android:name=".userinfoinput"/>
<!--
Set to true if your app is Standalone, that is, it does not require the handheld
app to run.
-->
<activity
android:name=".square"
android:label="#string/title_activity_square" />
<activity android:name=".MainActivity" />
</application>
And the error message is as following :
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nb_main, PID: 9057
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.nb_main/com.example.nb_main.login_nb}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3194)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:145)
at android.content.ComponentName.<init>(ComponentName.java:131)
at android.content.Intent.<init>(Intent.java:6510)
at com.example.nb_main.login_nb.<init>(login_nb.kt:24)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
at android.app.Instrumentation.newActivity(Instrumentation.java:1243)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3182)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/Process: Sending signal. PID: 9057 SIG: 9
Please tell me what I've done wrong. I use kotlin mainly, but I can somehow understand java also.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:145)
at android.content.ComponentName.<init>(ComponentName.java:131)
at android.content.Intent.<init>(Intent.java:6510)
at com.example.nb_main.login_nb.<init>(login_nb.kt:24)
In login_nb.kt row 24 there's some instance init code that instantiates an Intent. It's too early with regards to activity lifecycle. At init phase the activity is not yet ready to be used as a Context. The usual place for such init code is the activity's onCreate().
I have a react native Project that's integrated with onesignal notification, in Android app when I built my app using Android Studio it installs two apps one called onesignal and the other one my main app and app runs perfect
I tried to remove the intent from my activity
<activity android:name="bkholdnews.beonews.MainActivity" android:label="OneSignal Example" android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and rebuilt the app, it installs one app but when I open it it says app keeps stooping!
my MainActivity code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hhz20.bkholdnews"
android:versionCode="29"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <!-- Approximate location - If you want to use promptLocation for letting OneSignal know the user location. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Precise location If you want to use promptLocation for letting OneSignal know the user location. -->
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name="bkholdnews.beonews.MainApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true"
android:largeHeap="true"
android:supportsRtl="true"
android:label="#string/app_name"
android:icon="#drawable/icon"
android:theme="#style/SplashTheme">
<activity
android:launchMode="singleTop"
android:name="bkholdnews.beonews.SplashActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="bkholdnews.beonews.MainActivity" android:label="OneSignal Example" android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
</application>
</manifest>
CRASH LOGCAT
--------- beginning of crash
2019-06-01 17:31:18.598 30803-30803/com.hhz20.bkholdnews E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hhz20.bkholdnews, PID: 30803
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hhz20.bkholdnews/bkholdnews.beonews.SplashActivity}: android.content.res.Resources$NotFoundException: Drawable com.hhz20.bkholdnews:drawable/splash_screen with resource ID #0x7f0700b1
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.content.res.Resources$NotFoundException: Drawable com.hhz20.bkholdnews:drawable/splash_screen with resource ID #0x7f0700b1
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_screen.xml from drawable resource ID #0x7f0700b1
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:847)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:631)
at android.content.res.Resources.getDrawableForDensity(Resources.java:888)
at android.content.res.Resources.getDrawable(Resources.java:827)
at android.content.Context.getDrawable(Context.java:626)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:463)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:203)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
at android.support.v7.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at bkholdnews.beonews.SplashActivity.onCreate(SplashActivity.java:9)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <bitmap> requires a valid 'src' attribute
at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:849)
at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:770)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
2019-06-01 17:31:18.599 30803-30803/com.hhz20.bkholdnews E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1321)
at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:279)
at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:194)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:833)
... 27 more
2019-06-01 17:31:18.612 30803-30803/com.hhz20.bkholdnews I/Process: Sending signal. PID: 30803 SIG: 9
you might have to remove intent filter from main activity in the manifest file and start activity transaction through splash screen to main activity and also remove launchmode from mainactivity
Adding Google Ad Banners to my Android-Studio Project does not work.
I would be very very thankful, if anyone could help me. I just do not understand what I did wrong. :/
The tutorial I followed was: https://www.youtube.com/watch?v=w7muIkMYE_A
EDIT: Now I changed the code a bit and a new error occured.
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.codereddev.howtoandroidsoundboard">
...
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<!--
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/filepaths"/>
-->
<meta-data
android:name ="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<activity
android:name=".SoundboardActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FavoriteActivity" />
<!-- Necessary for sharing sounds on Android 5.1+ -->
<provider
android:authorities="${applicationId}.fileprovider"
android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
</provider>
</application>
</manifest>
No changes in my SoundboardActivity class:
public class SoundboardActivity
extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<ArrayList<SoundObject>> {
AdView mAdview;
...
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_soundboard);
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
mAdview = (AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
mAdview.loadAd(adRequest);
...
The new error is:
03-24 21:28:53.943 24135-24135/de.codereddev.howtoandroidsoundboard
E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.codereddev.howtoandroidsoundboard, PID: 24135
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
at android.app.ActivityThread.installProvider(ActivityThread.java:6396)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:608)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:579)
at android.support.v4.content.FileProvider.attachInfo(FileProvider.java:392)
at android.app.ActivityThread.installProvider(ActivityThread.java:6391)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Maybe the problem in the Manifest file..
Try Manifest the below type ..
<?xml version="1.0" encoding="utf-8"?>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Update your AndroidManifest.xml
Add your AdMob App ID to your app's AndroidManifest.xml file by adding a tag with name com.google.android.gms.ads.APPLICATION_ID, as shown below.
You can find your App ID in the AdMob UI. For android:value insert your own AdMob App ID in quotes, as shown below.
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
See more info in admob or GeetMark
This question already has answers here:
java.lang.ClassNotFoundException: Didn't find class on path: dexpathlist
(42 answers)
Closed 5 years ago.
I took an old project on the Internet, I decided to remake it for new versions of android.
I corrected it a little bit in the new version of android studio 3.0.
It seems that everything is fine. Like the project is going to be compiled without errors.
But when I run the application on a virtual device, the application crumbles.
Here is the error log:
01-09 02:43:25.140 1609-1609/com.locktest.lockscreen E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.locktest.lockscreen, PID: 1609
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.locktest.lockscreen/com.locktest.lockscreen.LockScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "com.locktest.lockscreen.LockScreenActivity" on path: DexPathList[[zip file "/data/app/com.locktest.lockscreen-1/base.apk"],nativeLibraryDirectories=[/data/app/com.locktest.lockscreen-1/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.locktest.lockscreen.LockScreenActivity" on path: DexPathList[[zip file "/data/app/com.locktest.lockscreen-1/base.apk"],nativeLibraryDirectories=[/data/app/com.locktest.lockscreen-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2538)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)*
at android.app.ActivityThread.-wrap12(ActivityThread.java)*
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)*
at android.os.Handler.dispatchMessage(Handler.java:102)*
at android.os.Looper.loop(Looper.java:154)*
at android.app.ActivityThread.main(ActivityThread.java:6077)*
at java.lang.reflect.Method.invoke(Native Method)*
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)*
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)*
As I understand it, the problem is:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.locktest.lockscreen.LockScreenActivity" on path: DexPathList[[zip file "/data/app/com.locktest.lockscreen-1/base.apk"],nativeLibraryDirectories=[/data/app/com.locktest.lockscreen-1/lib/x86, /system/lib, /vendor/lib]]
But how to decide - I do not know how to fix it.
Here is the manifesto:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.android.locktest.lockscreen"
tools:ignore="ExtraText">
<uses-permission-sdk-23 android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission-sdk-23 android:name="android.permission.WAKE_LOCK" />
<uses-permission-sdk-23 android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission-sdk-23 android:name="android.permission.READ_PHONE_STATE" />
<uses-permission-sdk-23 android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:name="android.support.multidex.MultiDexApplication">
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
<activity android:name="com.screen.locktest.lockscreen"
android:excludeFromRecents="true"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".utils.LockscreenService" />
<receiver android:name=".utils.LockscreenIntentReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
The crashlog says
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.locktest.lockscreen.LockScreenActivity" on path: DexPathList[[zip file "/data/app/com.locktest.lockscreen-1/base.apk"],nativeLibraryDirectories=[/data/app/com.locktest.lockscreen-1/lib/x86, /system/lib, /vendor/lib]]
while there is no LockScreenActivity in your manifest.
If this is how you are defining the activity:
<activity android:name="com.screen.locktest.lockscreen"
android:excludeFromRecents="true"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
You need to add the class name as well android:name="com.screen.locktest.lockscreen.LockScreenActivity"
Today I found some projects, which demonstrates android ndk programming. Here is this projects
I'm trying to start project DroidBlaster. I have compiled all native libraries without errors. Here is result:
I just made some small changes:
1). Added to application tag in AndroidManifest.xml option android:hasCode="true"
2). I extended from native activity and load all libraries in static block of activity.
I did this, because, without this changes, android can't find library libdroidblaster.so which was declared in AndroidManifest.xml(Here is code from author):
<activity
android:name="android.app.NativeActivity"
android:label="#string/app_name" >
<meta-data
android:name="android.app.lib_name"
android:value="droidblaster" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Now my AndroidManifest.xml looks like:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.droidblaster"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="22" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:hasCode="true">
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="android.app.NativeActivity"
android:label="#string/app_name" >
<meta-data
android:name="android.app.lib_name"
android:value="droidblaster" />
</activity>
</application>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
</manifest>
And my new activity:
public class MainActivity extends NativeActivity {
static {
System.loadLibrary("irrlicht");
System.loadLibrary("droidblaster");
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
When I try to start app, I get this error:
06-05 12:56:26.523 11528-11528/com.demo.droidblaster
E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.demo.droidblaster, PID: 11528
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.demo.droidblaster/com.demo.droidblaster.MainActivity}:
java.lang.IllegalArgumentException: Unable to find native library:
main
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalArgumentException: Unable to find native library: main
at android.app.NativeActivity.onCreate(NativeActivity.java:170)
at com.demo.droidblaster.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
So, the cause is:
java.lang.IllegalArgumentException: Unable to find native library: main
I can't find a solution to fix this problem.
Does anyone know how to fix it?
.so files are not automatically included by Android Studio. Follow the answer given here to include them: https://stackoverflow.com/a/17131418/1395437
You can try to install new gradle with ndk-support integration(experemental). http://ph0b.com/new-android-studio-ndk-support/#more-236
There would be android.ndk box (in your gradle.build) where you should add native_android_glue :
android.ndk{
moduleName = "droidblaster"
CFlags.add("-I${file("src/main/jni/android_native_app_glue")}".toString())
ldLibs.addAll(["log", "android", "EGL", "GLESv1_CM"])
}
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared" //add this in the build.gradle
}
}
I think you have to remove your second activity and add this tag <meta-data android:name="android.app.lib_name" android:value="droidblaster" /> to your first activity
change NativeActivity to AppCompatActivity.