This question already has answers here:
Android app ClassNotFoundException for main activity
(13 answers)
Closed 12 months ago.
I am trying to build a app with Google API and i followed every steps that was given on internet to how to work with Google API, but when i run my app it launch and then closes instantly.
Logcat
04-21 19:07:19.857 16778-16778/? I/art: Late-enabling -Xcheck:jni
04-21 19:07:19.858 16778-16778/? I/art: Reinit property: dalvik.vm.checkjni= false
04-21 19:07:20.052 16778-16778/com.example.kakarot.cpecroute W/System: ClassLoader referenced unknown path: /data/app/com.example.kakarot.cpecroute-1/lib/arm64
04-21 19:07:20.065 16778-16778/? I/InstantRun: starting instant run server: is main process
04-21 19:07:20.074 16778-16778/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.kakarot.cpecroute, PID: 16778
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.kakarot.cpecroute/com.example.kakarot.cpecroute.MapsActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.kakarot.cpecroute.MapsActivity" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.kakarot.cpecroute-1/base.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.kakarot.cpecroute-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2698)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2870)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6605)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:999)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:889)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.kakarot.cpecroute.MapsActivity" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.kakarot.cpecroute-1/base.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.kakarot.cpecroute-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.kakarot.cpecroute-1/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
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:1083)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2688)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2870)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1573)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6605)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:999)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:889)
04-21 19:07:20.083 16778-16778/? I/Process: Sending signal. PID: 16778 SIG: 9
.............................................................................
AndroidManifest.xml/activity
#Sagar Yes, there is a activity in AndroidManifest.xml.
Below is code
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Try this :
<activity android:name="com.yourpackagename.MapsActivity" android:label="#string/title_activity_maps"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Let me know is this works or not
I have resolved this issue by upgrading my Gradle plugin version to 7.1.1:
classpath 'com.android.tools.build:gradle:7.1.1'
Related
I am trying to create an app to block the installation of a certain app based on the package name. I tried the BroadcastReceiver method but the app seems to crash. and thank you for reviewing this and for the help.
here is my BroadcastReceiver class:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MyReceiver extends BroadcastReceiver {
Context context;
String log = MyReceiver.class.getName();
#Override
public void onReceive(Context context, Intent intent) {
this.context = context;
if(intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")){
Toast.makeText(context,"Package removed", Toast.LENGTH_LONG).show();
Log.d(log,"Package removed");
}
if(intent.getAction().equals("android.intent.action.PACKAGE_ADDED")){
Toast.makeText(context, "Package installed", Toast.LENGTH_SHORT).show();
Log.d(log,"Package installed");
}
}
}
manifest:
<receiver
android:name="MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="100">
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
crash log:
10-12 22:18:22.836 15429-15429/com.example.mohammed.broadcastreceiver E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mohammed.broadcastreceiver, PID: 15429
java.lang.RuntimeException: Unable to instantiate receiver com.example.mohammed.broadcastreceiver.MyReceiver: java.lang.ClassNotFoundException: Didn't find class "com.example.mohammed.broadcastreceiver.MyReceiver" on path: DexPathList[[zip file "/data/app/com.example.mohammed.broadcastreceiver-1/base.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.mohammed.broadcastreceiver-1/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3287)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1719)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.mohammed.broadcastreceiver.MyReceiver" on path: DexPathList[[zip file "/data/app/com.example.mohammed.broadcastreceiver-1/base.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.mohammed.broadcastreceiver-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.mohammed.broadcastreceiver-1/lib/arm64, /system/lib64, /vendor/lib64]]
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.ActivityThread.handleReceiver(ActivityThread.java:3282)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1719)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
You've registered your Receiver incorrectly.
The crash log says it can't find MyReceiver in the root of your project (which is where you've said it exists in your Manifest), but it looks like it isn't.
Make sure the name attribute points to the actual location.
I had developed app on android studio 3.0.1, but I got a error when I installed the apk to my cellphone.
Cellphone connect mac by usb, click run button
,the apk will installed and run no error. But if I copy the apk in finder (like this)
to cellphone and install it in phone, there will be an error "APK parsing error".
If install apk by "adb install xxx.apk" ,when open the app, it will crash and logcat as follow:
12-20 16:35:09.562 14658-14658/? I/art: Late-enabling -Xcheck:jni
12-20 16:35:09.562 14658-14658/? I/art: Reinit property: dalvik.vm.checkjni= false
12-20 16:35:09.614 14658-14658/com.xxx.xxx I/InstantRun: starting instant run server: is main process
12-20 16:35:09.620 14658-14658/com.xxx.xxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 14658
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm64, /data/app/com.xxx.xxx-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2695)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.MainActivity" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm64, /data/app/com.xxx.xxx-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]
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:1083)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2685)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
12-20 16:35:09.624 14658-14658/com.xxx.xxx I/Process: Sending signal. PID: 14658 SIG: 9
But if click Bulid>Build APK(s) , then copy the apk in same folder (this : apk)to cellphone, it will install and run with no error...
is it a bug in android studio?
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxx">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In new version VS, You shold use "Bulid Apk" menu option to generate the product apk :)
try with disable Instant Run . it find at
Run Goto File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run
before this uninstall previous app from device.
I believe what is causing it is a stack trace.
I am going through the official Android app bulding tutorial here: https://developer.android.com/training/index.html
I finished the "Start Another Activity" section and have found this error while trying to test it. I was also not able to run the app in the earlier parts of the tutorial.
That led me to this link: Unfortunately MyApp has stopped. How can I solve this?
Which led me to this link:
What is a stack trace, and how can I use it to debug my application errors?
But I am still having trouble figuring it out.
Here is a snippet of the error log:
12-14 09:52:06.962 3696-3696/com.example.myfirstapp I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
12-14 09:52:06.962 3696-3696/com.example.myfirstapp I/zygote: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
12-14 09:52:06.962 3696-3696/com.example.myfirstapp I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
12-14 09:52:06.962 3696-3696/com.example.myfirstapp D/AndroidRuntime: Shutting down VM
12-14 09:52:06.964 3696-3696/com.example.myfirstapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myfirstapp, PID: 3696
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.myfirstapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/base.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/lib/x86, /system/lib, /vendor/lib]]
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.ClassNotFoundException: Didn't find class "com.example.myfirstapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/base.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
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)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
12-14 09:52:06.964 3696-3696/com.example.myfirstapp E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 12 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/base.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.myfirstapp-R68LcIdIMck0utpOhrKfsA==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 15 more
Any suggestions on how to figure this out? Thanks!
Edit:
I believe this is my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp">
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DisplayMessageActivity"
android:parentActivityName=".MainActivity" >
<!-- The meta-data tag is required if you support API level 15 and lower -->
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
</manifest>
You have incorrect closing tag in your manifest:
<activity android:name=".DisplayMessageActivity"
android:parentActivityName=".MainActivity" >
<!-- The meta-data tag is required if you support API level 15 and lower -->
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
This is the incorrect closing tag without open tag:
<!-- The meta-data tag is required if you support API level 15 and lower -->
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
Try removing it.
UPDATED:
From the tutorial, you're missing the open tag of <meta-data, so you need to correct it by adding the open tag:
<meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" />
After adding the tag, your code will be like this:
<activity android:name=".DisplayMessageActivity"
android:parentActivityName=".MainActivity" >
<!-- The meta-data tag is required if you support API level 15 and lower -->
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
Trying to build and run an app in Android Studio 2.2.2 that does work in Eclipse. When I try to debug it (on a Samsung Galaxy tab 4) I get: (BTW is there any way to get this to come out more readably in StackOverflow?)
I/System.out: waiting for debugger to settle... I/System.out: debugger
has settled (1484) I/InstantRun: Instant Run Runtime started. Android
package is com.xxxxxxx.remote, real application class is null.
W/InstantRun: No instant run dex files added to classpath
D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.xxxxxxx.remote, PID: 1925
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.xxxxxxx.remote/com.xxxxxxx.remote.RemoteControlActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.xxxxxxx.remote.RemoteControlActivity" on path: DexPathList[[zip
file
"/data/app/com.xxxxxxx.remote-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2644)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1476)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
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.ClassNotFoundException: Didn't find class "com.xxxxxxx.remote.RemoteControlActivity" on path:
DexPathList[[zip file
"/data/app/com.xxxxxxx.remote-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2634)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2867)
...etc...
I've "xxxxx"'ed out a proprietary name. What do real application class is null and No instant run dex files added to classpath mean? Also I see the reference to "Unable to instantiate activity ComponentInfo" in a lot of similar questions - what does it mean?
The activity it can't find is declared in the manifest as...
<activity android:launchMode="singleTask"
android:label="#string/app_name"
android:windowNoTitle="false"
android:configChanges="orientation"
android:screenOrientation="landscape"
android:name=".RemoteControlActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I can't even hit a breakpoint at the beginning of the Activity, so how do I debug this?
You can disable InstantRun and see if the problem persists.
This question already has answers here:
Android ClassNotFoundException: Didn't find class on path
(37 answers)
Closed 8 years ago.
The error I describe below, occurs when:
Install the app on a device directly from the APK.
Download the app by Play Store
The error don´t occurs when:
Install apk through Eclipse pressing the 'run' button
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.package/my.package.MainActivity}:
java.lang.ClassNotFoundException: my.package.MainActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1998)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2099)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4929)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: my.package.MainActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1056)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1989)
... 11 more
To export the APk I do as always, from "Use the Export Wizard to export and sign an APK"
Any idea because it occurs from the APK but not directly from eclipse?
The above error is generated by me. But reports of users are somewhat different:
User1:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{my.package/my.package.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"my.package.MainActivity" on path: DexPathList[dexElements=[zip file
"/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1,
/vendor/lib, /system/lib]]
User2:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{my.package/my.package.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"my.package.MainActivity" on path: DexPathList[[zip file
"/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1,
/vendor/lib, /system/lib]]
Manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package"
android:versionCode="12"
android:versionName="2.3" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/motion"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/Theme.AppCompat.Light" >
<activity
android:name="my.package.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>
<activity android:name="my.package.AlarmsListActivity"
android:theme="#style/dialogTheme"/>
<activity android:name="my.package.ImagenesActivity"/>
<activity android:name="my.package.EndActivity" />
</application>
</manifest>
I use the following libraries in MainActivity
This is your error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.package/my.package.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "my.package.MainActivity" on path: DexPathList[dexElements=[zip file "/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1, /vendor/lib, /system/lib]]
Solution:
You have added library project as a reference to your project and also may be you have added jar files for ChartView and support-v7 in your libs folder and also as a Add External Jars. So you have to enable both checkboxes for android-support-v7.jar file and for chartview jar file in order and export menu.
The path for it is,
Project - Right Click - Properties - Java Build Path - Order and Export Menu.
Finally you need to clean and run your project.