android debug apk crashing but release apk run successfully - android

While running apk from android studio via adb it is working/running properly. but when i am giving that debug apk to my client it is crashing. but when i am giving signed apk it is working fine.
The debug apk installed successfully but when it going to run then it get "class not found error".
09-19 20:05:12.065 29019-29019/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.volansys.homebridge, PID: 29019
java.lang.RuntimeException: Unable to instantiate application com.volansys.homebridge.HomeBridgeApplication: java.lang.ClassNotFoundException: Didn't find class "com.volansys.homebridge.HomeBridgeApplication" on path: DexPathList[[zip file "/data/app/com.volansys.homebridge-2/base.apk"],nativeLibraryDirectories=[/data/app/com.volansys.homebridge-2/lib/arm, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5376)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.volansys.homebridge.HomeBridgeApplication" on path: DexPathList[[zip file "/data/app/com.volansys.homebridge-2/base.apk"],nativeLibraryDirectories=[/data/app/com.volansys.homebridge-2/lib/arm, /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.newApplication(Instrumentation.java:1014)
at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5376) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 
i also changed the manifest file and gave the whole path to the application class like
android:name="package_name.HomeBridgeApplication"
When i going to ctrl+click on this class it can navigate to this class. it means path is proper so why i am getting class not found error ?
can anyone help me ?
Thanks in Advance.

Related

Unable to instantiate application class

8-03 11:35:19.736 5040-5043/? E/ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
08-03 11:35:19.863 16408-16408/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app, PID: 16408
java.lang.RuntimeException: Unable to instantiate application com.app: java.lang.ClassNotFoundException: Didn't find class "com.app" on path: DexPathList[[zip file "/data/app/com.app-2/base.apk"],nativeLibraryDirectories=[/data/app/com.app-2/lib/arm, /data/app/com.app-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5376)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.app" on path: DexPathList[[zip
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.newApplication(Instrumentation.java:1014)
at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5376) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6123) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 
08-03 11:35:19.983 1490-1523/? E/BatteryStatsService: no controller energy info supplied
Solved above problem by disabling the instant Run
I have seen this problem on more than one thread and it is almost always that the Application class name is absent, misspelled, misnamed, or in the wrong package in the manifest.
Double check your manifest and notice if the Application name is set and if it is green or red? Your app will compile even if it is red--or indicating that there is an error.
BTW this happened to me with Instant Run disabled. Instant Run is often named as the culprit when clearly the classloader cannot find the Application class, because of a name related problem.

Why the unsigned application does not find the Application class?

The application that I am developing is crashing in some mobiles when it is not signed. When I sign the application, it works perfectly on the same devices that previously made the application crashes.
The error is:
Process: com.my.application, PID: 10293 java.lang.RuntimeException: Unable to instantiate application com.my.application.di.base.App: java.lang.ClassNotFoundException: Didn't find class "com.my.application.di.base.App" on path: DexPathList[[zip file "/data/app/com.my.application-1/base.apk"],nativeLibraryDirectories=[/data/app/com.my.application-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:563)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4526)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.my.application.di.base.App" on path: DexPathList[[zip file "/data/app/com.my.application-1/base.apk"],nativeLibraryDirectories=[/data/app/com.my.application-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.Instrumentation.newApplication(Instrumentation.java:980)
at android.app.LoadedApk.makeApplication(LoadedApk.java:558)
... 10 more
Suppressed: java.lang.ClassNotFoundException: com.my.application.di.base.App
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
I'm not obfuscating my code, nor use instant run. I'm using multidex.
For creating debug apk create it from Build>Build APK. The issue you are facing is because of instant run.
Do you use proguard or any other method to obfuscate your code?
I think you should use multidex

Android Application crashed when share debug APK from output folder

I am working on one application that have only one screen barcode scanning and I am achieve this with zxing Library. But my problem is if I am install app with android studio it is working fine but if I share this apk from output folder with Bluetooth, Email, Xender, etc.. Application is install but when I open the app it will crash and Exception is NoClassFoundException.
Here is Logcat:
FATAL EXCEPTION: main
Process: com.jenex.cartracking, PID: 31223
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.jenex.cartracking/com.jenex.cartracking.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.jenex.cartracking.MainActivity" on path: DexPathList[[zip file "/data/app/com.jenex.cartracking-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3029)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
at android.app.ActivityThread.access$1000(ActivityThread.java:211)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6946)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.jenex.cartracking.MainActivity" on path: DexPathList[[zip file "/data/app/com.jenex.cartracking-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:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3019)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300) 
at android.app.ActivityThread.access$1000(ActivityThread.java:211) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6946) 
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:1404) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
Suppressed: java.lang.ClassNotFoundException: com.jenex.cartracking.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
You have to clean build before share the app and make a debug build.
Follow this simple steps,
Goto Build -> Clean Project
Goto Build -> Build Apk
This will generate build Apk. Share this Apk.
Hope this helps.
It seems like I have the same problem. Such an exception happens now with any project, even with empty and clean just created. I used to share myproject_debug.apk with testers, but now it crashes on start up. Maybe it started after some update of Android Studio or platform-tools, I'm not sure.
So, I found some work around that work for me
Before copy project-debug.apk from output folder:
go to menu in Android Studio and open menu 'Build'
click 'Build APK'
After successful build I copy myproject-debug.apk from output folder and it works well.

APK doesn't work on phone but App works normal in Android Studio

I have an App that works without problems in Android Studio, but when I Build the apk and then install it shows stranges behaviors:
1- When App is installing, phone shows me notification that no one permission is necessary for my app (and that is not true, my app works with awareness)
2- After installation, and running, the App crushed, no one screen is showed.
I was thinking that maybe could be a problem with manifest, but as I said in emulator works without problem. First time I see this behavoir. Any idea how to solve it ??
03-28 13:15:22.851 7334-7334/com.itelma.tele D/AndroidRuntime: Shutting down VM
03-28 13:15:22.851 7334-7334/com.itelma.tele E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.itelma.tele, PID: 7334
java.lang.RuntimeException: Unable to instantiate service com.itelma.tele.API_AC.FCMInstanceIdService: java.lang.ClassNotFoundException: Didn't find class "com.itelma.tele.API_AC.FCMInstanceIdService" on path: DexPathList[[zip file "/data/app/com.itelma.tele-2/base.apk"],nativeLibraryDirectories=[/data/app/com.itelma.tele-2/lib/arm, /data/app/com.itelma.tele-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3841)
at android.app.ActivityThread.access$2100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1909)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.itelma.tele.API_AC.FCMInstanceIdService" on path: DexPathList[[zip file "/data/app/com.itelma.tele-2/base.apk"],nativeLibraryDirectories=[/data/app/com.itelma.tele-2/lib/arm, /data/app/com.itelma.tele-2/base.apk!/lib/armeabi-v7a, /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.handleCreateService(ActivityThread.java:3838)
at android.app.ActivityThread.access$2100(ActivityThread.java:229) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1909) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7325) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Suppressed: java.lang.ClassNotFoundException: com.itelma.tele.API_AC.FCMInstanceIdService
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)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

After updating Android Studio to 2.3 , my app works fine in device ( Nexus 5X) but it crash every time when i install the apk explicitly

I did these things:
1) Clean the code and remove everything in /build folder.
2) Analyse AndroidManifest.xml file all activities have proper package name as suffix
Multidex is already enabled
These are the Error Logs i got every time.:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.packagename, PID: 25752
java.lang.RuntimeException: Unable to instantiate application
com.android.packagename.BaseApplication:
java.lang.ClassNotFoundException: Didn't find class
"com.android.packagename.BaseApplication" on path: DexPathList[[zip
file
"/data/app/com.android.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.android.packagename-1/lib/arm64,
/system/lib64, /vendor/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.android.packagename.BaseApplication" on path: DexPathList[[zip
file
"/data/app/com.android.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.android.packagename-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.Instrumentation.newApplication(Instrumentation.java:992)
at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Ok try to install instant run for your target api
Or disable instant run from Android studio
More about instant run
Preferences->Build,Execution,Deployment->instant Run
then,
function

Categories

Resources