8

This is the error everytime I run the app:

    E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application com.xxxxx.App: java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk
    at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4657)
    at android.app.ActivityThread.access$1400(ActivityThread.java:159)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.Instrumentation.newApplication(Instrumentation.java:992)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4657) 
    at android.app.ActivityThread.access$1400(ActivityThread.java:159) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:176) 
    at android.app.ActivityThread.main(ActivityThread.java:5419) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:525) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
    at dalvik.system.NativeStart.main(Native Method)

Here some info:

JavaVersion.VERSION_1_8        (I cannot use 1.7 because of a library)
buildToolsVersion '24.0.0'
compileSdkVersion & target 24  (also tried 23)
gradle 2.2.0-alpha4            (also tried with 2.1.0)

I have instant run disabled.

I have a class named App that extends Application, so in AndroidManifest.xml I have <application android:name="com.xxxxx.App"

Please don't mark this question as duplicate, because I have already tried all the solutions given, but I cannot get rid of this error.

 

David P
  • 1,023
  • 10
  • 17
  • did you check this answer : http://stackoverflow.com/questions/22399572/java-lang-classnotfoundexception-didnt-find-class-on-path-dexpathlist – Harshad Pansuriya Jul 07 '16 at 08:42
  • yes, but no success – David P Jul 07 '16 at 08:49
  • Observed same, looks like a bug related with that latest build tools updates. – sandrstar Jul 08 '16 at 01:33
  • I have the same issue when compile my application with Java 8. However, I have to notice that I created another clear application with a lot of dependencies just to simulate multiDex and it works well. This behavior is observing only on Android prior to 5. App works well with the same preconditions on Android 5 and later. – Yuriy Chernyshov Oct 21 '16 at 12:21

4 Answers4

3

I was having the same error and just cleaning the project solve it for me. it seems a bug in the new version of android studio.

humazed
  • 74,687
  • 32
  • 99
  • 138
2

remove the app from your mobile phone then build => clean project and try installing again

farhang67
  • 759
  • 2
  • 14
  • 27
1

Have you tried running the app on another device/emulator?
I experienced this problem once because I was the 2nd user on the device that I was trying to run it on. If that's the case, you will have to switch to the primary user(owner) every time you wish to run your app.

Sajal Narang
  • 397
  • 1
  • 14
0

I was having the same issue, then tried creating the same application class in java instead of kotlin and it worked.

sf_admin
  • 577
  • 4
  • 11