Fatal Exception - unable to instantiate activity - real application class is null - android

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.

Related

debug APK parsing error (generate by click android studio run button)

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.

Install referrer receiver was accidentally left in the manifest file after I removed the referrer SDK

I have removed the appnext SDK from my project. However, I forgot to remove the appnext install referral receiver. The version passed gradle build without any error or warning even though it should have failed the build! (Since I referenced an SDK that was no longer part of the project). My question is why Android Studio/Gradle didn't at least warned me about it at build time?
Here is the relevant code snippet from my manifest file:
The AppsFlyer Install Receiver is first and will broadcast to all receivers placed below it.
Although the library provides additional services, if you use ProGuard as part of your build process,
it has a light footprint. We only use the ads packages from Google Services.
If you want to optimize the size of your project you can exclude any other packages.
For more details see: https://support.appsflyer.com/hc/en-us/articles/207032126-AppsFlyer-SDK-Integration-Android
-->
<receiver
android:name="com.appsflyer.MultipleInstallBroadcastReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<!-- appnext install referral receiver -->
<receiver
android:name="com.appnext.appnextsdk.ReferralReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
You can also see the exception stack trace below (just a bit too late :( ):
Fatal Exception: java.lang.RuntimeException: Unable to instantiate receiver com.appnext.appnextsdk.ReferralReceiver: java.lang.ClassNotFoundException: Didn't find class "com.appnext.appnextsdk.ReferralReceiver" on path: DexPathList[[zip file "/data/app/com.infibond.infi-1/base.apk"],nativeLibraryDirectories=[/data/app/com.infibond.infi-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2992)
at android.app.ActivityThread.access$1800(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by java.lang.ClassNotFoundException: Didn't find class "com.appnext.appnextsdk.ReferralReceiver" on path: DexPathList[[zip file "/data/app/com.infibond.infi-1/base.apk"],nativeLibraryDirectories=[/data/app/com.infibond.infi-1/lib/arm, /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.ActivityThread.handleReceiver(ActivityThread.java:2987)
at android.app.ActivityThread.access$1800(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
The exception stack trace above is clear to me and very logical. After all I have removed the app next library from my project and that was a left over I forgot. Why it happened is not my question, my question is why the Android Studio would let me compile & build my project without raising a single warning in the gradle console? I have not changed any default lint properties. Moreover, When I open the manifest file now Android Studio, would mark the line "android:name="com.appnext.appnextsdk.ReferralReceiver" as an error. But when I built the project is will not even warn me about that.

Android: Rare and Non-Reproducible ClassNotFoundException

I have a published app that gets reports about a ClassNotFoundExceptionfrom users that I went beyond my wits end trying to fix. I have not been able to reproduce this crash and similar instances of this error here on SO have either been cases of incorrect path to a dependency or a different package in the MainActivity than the manifest.
The issues with the wrong path to the dependencies are an Eclipse thing, while all the other errors could be easily fixed with Android Studio's "sync" and "clean project" (which I did to no avail).
I've triple checked all the package names and did not find any discrepancies.
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.johan.fsc">
<uses-permission android:name = "android.permission.VIBRATE"/>
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:fullBackupContent="true">
<activity
android:name="com.johan.fsc.MainActivity"
android:screenOrientation="portrait"
android:label="#string/app_name"
android:theme="#style/splashscreenTheme"
android:hardwareAccelerated="false"
android:largeHeap="true">>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name = "com.johan.fsc.SettingsActivity"
android:theme="#style/PreferencesTheme"/>
</application>
Here is the error report I always get from users:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.johan.fsc/com.johan.fsc.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.johan.fsc.MainActivity" on path: DexPathList[[zip file "/data/app/com.johan.fsc-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5624)
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:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.johan.fsc.MainActivity" on path: DexPathList[[zip file "/data/app/com.johan.fsc-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:1071)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
... 10 more
Suppressed: java.io.IOException: Failed to open oat file from dex location '/data/app/com.johan.fsc-1/base.apk'
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:295)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:262)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:231)
at dalvik.system.DexPathList.<init>(DexPathList.java:109)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:57)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:370)
at android.app.LoadedApk.makeApplication(LoadedApk.java:562)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4818)
at android.app.ActivityThread.access$1500(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1531)
... 7 more
Caused by: java.io.IOException: Failed to open oat file from /data/app/com.johan.fsc-1/arm/base.odex (error Failed to open oat filename for reading: No such file or directory) (no dalvik_cache availible) and relocation failed.
... 22 more
Caused by: java.io.IOException:
... 22 more
Caused by: java.io.IOException: Failed to remove obsolete file from /data/dalvik-cache/arm/data#app#com.johan.fsc-1#base.apk#classes.dex when searching for dex file /data/app/com.johan.fsc-1/base.apk: Permission denied
... 22 more
Suppressed: java.lang.ClassNotFoundException: com.johan.fsc.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available/output.
It would seem that the culprit is java.io.IOException: Failed to remove obsolete file from /data/dalvik-cache/arm/data#app#com.johan.fsc-1#base.apk#classes.dex when searching for dex file /data/app/com.johan.fsc-1/base.apk: Permission denied, but I have not found why it's being invoked for some users and not the majority, and more importantly--how to fix it.
Possible Cause 1: There is a typo in the manifest in the line android:largeHeap="true">>. xml line ends with >>. This may be preventing the Intent-Filter from executing.
Possible Cause 2: My guess is that the phone is searching for a class <PackageName>.<PackageName>.<ClassName> instead of <PackageName>.<ClassName> . So definitely <PackageName>.<PackageName>.<ClassName> is not found and ClassNotFoundException would be the result. In android studio, in the manifest, by default activity name is written like this: android:name=".<ClassName>" instead of android:name="<PackageName>.<ClassName>" . You can give this a try.
Most phones may be checking whether packagename is added before the class name in the manifest. If it is added then they don't add it while searching of the class. While few phones must be adding the package name by default while searching for the class. Hence, they cannot find your class.
Certainly, you're naming your activity wrong. An activity CAN NOT consist the package's name in its name attribute.
Since you're already defining the package name here
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.johan.fsc">
You shouldn't mention that name here
<activity android:name="com.johan.fsc.MainActivity"
The only situation you should use package name along with a class's name is when the java class resides in a different package, as done in import statements.
Even if your activity is not present in the src folder and is instead present in a nested folder, android studio should handle the linking of manifest and the activity itself. Yet again, package name shouldn't be used there.

Android Studio Manifest error - saying package does not exist

I refactored my package name and put my CuteMainActivityin the package org.azurespot.cutemain.CuteMainActivity. Plus rearranged all my other classes. So now I get a red error on the .CuteMainActivity part in my Manifest, where the activity should launch.
I also changed the top package name of my Manifest to the new one: org.azurespot, and also changed my applicationID in my build.gradle file to the new package name org.azurespot too. Then I rebuilt, cleaned, and even tried invalidate and restart to my project but nothing is getting rid of this red error. I also tried to assign the new package/activity name to launch in my run configurations, and got this error:
Launching application: org.azurespot/org.azurespot.cutemain.CuteMainActivity.
DEVICE SHELL COMMAND: am start -n "org.azurespot/org.azurespot.cutemain.CuteMainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.azurespot/.cutemain.CuteMainActivity }
Error type 3
Error: Activity class {org.azurespot/org.azurespot.cutemain.CuteMainActivity} does not exist
One strange thing, is that my package name has the word (androidTest) beside it. Would that make things not work? Usually studio creates a regular package name and a package_name (androidTest), but in the refactoring, I only see this (androidTest) one.
I have been researching this problem for a while, but nothing seems to work. Any suggestions? Thank you.
Manifest.java
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.azurespot" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".CuteMainActivity" //This has a red error
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>
</manifest>
LogCat after changed Manifest name to ".cutemain.CuteMainActivity"
1480-1480/org.azurespot E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: org.azurespot, PID: 1480
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.azurespot/org.azurespot.cutemain.CuteMainActivity}: java.lang.ClassNotFoundException: Didn't find class "org.azurespot.cutemain.CuteMainActivity" on path: DexPathList[[zip file "/data/app/org.azurespot-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.azurespot-2, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.azurespot.cutemain.CuteMainActivity" on path: DexPathList[[zip file "/data/app/org.azurespot-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.azurespot-2, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
You should change it to one of the followings:
android:name="org.azurespot.cutemain.CuteMainActivity"
or
android:name=".cutemain.CuteMainActivity"
Ah... the package name with (androidTest) was indeed the culprit. All of the above answers should have fixed things, but the final problem was that when I refactored (I have no idea how it happened), all of my new package names got put into my androidTest directory in the src folder, and nothing was in my main of my src folder. So when my app went looking for the main activity, it could not be found. The fix to this was to put the whole java folder back into the main folder (as it was empty for some reason), then restart the app and everything worked again. It was not necessary to delete the androidTest folder, and it seems fine that it's empty.

java.lang.ClassNotFoundException when install app from APK [duplicate]

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.

Categories

Resources