1

After I run gradle clean and build and upload apk on device my app crash on start with following exception. I use Android Studio 1.3.1.

  java.lang.RuntimeException: Unable to instantiate application my.package.MyApplication: java.lang.ClassNotFoundException: Didn't find class "my.package.MyApp" on path: DexPathList[[zip file "/data/app/com.unated-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
        at android.app.LoadedApk.makeApplication(LoadedApk.java:569)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4589)
        at android.app.ActivityThread.access$1500(ActivityThread.java:149)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1385)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:211)
        at android.app.ActivityThread.main(ActivityThread.java:5317)
        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:1016)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unated.ProductionApp" on path: DexPathList[[zip file "/data/app/com.unated-2/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)
 Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

I have 2 flavors: production and staging. And I have two different Application classes for each flavor. I read RuntimeException: Unable to instantiate application but killing app from recent list does not work. If I change flavor then some times app starts to work. And sometimes if I change flavor back it starts to work (but often not). I can not figure out how to make it work. Very annoying thing, please help!

1 Answer 1

2

Add below code segment in your build.gradle in app module.

dexOptions {
  preDexLibraries false
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.