Unable to instantiate application class - android

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.

Related

android debug apk crashing but release apk run successfully

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.

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

MultiDex issue: java.lang.ClassNotFoundException: Didn't find class on path: DexPathList

I am facing an issue with my app:
If I deactivate within Android Studio Instant Run, my app crashes upon startup with the stacktrace:
12-29 13:36:37.876 4549-4549/com.mycoolapp.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycoolapp.debug, PID: 4549
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycoolapp.debug/com.myapp.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "com.myapp.SplashScreenActivity" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.mycoolapp.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycoolapp.debug-2/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2216)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
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:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.SplashScreenActivity" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.mycoolapp.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycoolapp.debug-2/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.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365) 
at android.app.ActivityThread.access$800(ActivityThread.java:148) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5272) 
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:909) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704) 
Suppressed: java.lang.NoClassDefFoundError: com.myapp.SplashScreenActivity
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more
Suppressed: java.lang.ClassNotFoundException: com.myapp.SplashScreenActivity
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
As far as I have researched this belongs to multidex:
https://developer.android.com/studio/build/multidex.html
Even if I add the multiDexEnabled property to my gradle config the app crashes. Only if I enable InstantRun (which enables multidex in background), the app runs...
If I create an apk the installation works, but the app crashes on startup with the same error.
Since I have as minSDK API Level 21, there should be no other change except of the multiDexEnabled property necessary, right?
So last but not least my answer:
All my configuration for multidex was correct... I don't know why, but after a complete OS restart everything works fine now... :)
Just create new phone on AVD and try to install app on that phone. Hope it will work.
The accepted answer was only a temporary fix for me, after altering code and a few builds the error came back.
After alot of trial and error the real problem was the jdk location my project was using, instead of using the embedded jdk in android studio i was using an installed version from oracle. After going to File > Project Structure > SDK Location and checking Use embedded JDK the problem was fixed for good.
Check if your classpath
'com.android.tools.build:gradle:3.1.0-alpha05'
is up-to-date, had same problem and solved it with a full update.

When ever i was run my android app it indicate error but no error in the code . Error is given below

10-20 20:18:53.146 19159-19159/? I/art: Late-enabling -Xcheck:jni
10-20 20:18:53.221 19159-19159/com.example.deeps.myapplication D/AndroidRuntime: Shutting down VM
10-20 20:18:53.222 19159-19159/com.example.deeps.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.deeps.myapplication, PID: 19159
java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/com.example.deeps.myapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:563)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4504)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5235)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/com.example.deeps.myapplication-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.newApplication(Instrumentation.java:979)
at android.app.LoadedApk.makeApplication(LoadedApk.java:558)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4504) 
at android.app.ActivityThread.access$1500(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5235) 
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:898) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693) 
Suppressed: java.lang.ClassNotFoundException: com.android.tools.fd.runtime.BootstrapApplication
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
10-20 20:18:53.253 19159-19159/? I/Process: Sending signal. PID: 19159 SIG: 9
Pls try all of these options and me know the outcome. I think disabling Instant run will solve this problem but please do clean/rebuild project once too.
Disable the Instant Run option in Android Studio. To disable Instant Run Go to File --> Settings--> Build,Execution,Deployment -->Instant Run ---> uncheck "Enable instant run"
Android Studio menu - Build --> Rebuild Project.
If this does not work then try this too.
Change gradle build version to
classpath 'com.android.tools.build:gradle:1.2.3'

Categories

Resources