Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to instantiate application on startup #155

Closed
CurralesDragon opened this issue Mar 9, 2018 · 2 comments
Closed

Unable to instantiate application on startup #155

CurralesDragon opened this issue Mar 9, 2018 · 2 comments

Comments

@CurralesDragon
Copy link

CurralesDragon commented Mar 9, 2018

Description

Really looking forward to use this, thanks for sharing.
But I'm having trouble getting an application set-up.

Once i run my app i get an exception:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example, PID: 4606
                  java.lang.RuntimeException: Unable to instantiate application com.example.exampleApplication: java.lang.ClassNotFoundException: Didn't find class "com.example.exampleApplication" on path: DexPathList[[zip file "/data/app/com.example-b2AaI9HdMFVibhYyMrBrNQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example-b2AaI9HdMFVibhYyMrBrNQ==/lib/x86, /system/lib, /vendor/lib]]
                      at android.app.LoadedApk.makeApplication(LoadedApk.java:971)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5765)
                      at android.app.ActivityThread.-wrap1(Unknown Source:0)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
                      at android.os.Handler.dispatchMessage(Handler.java:105)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6541)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.exampleApplication" on path: DexPathList[[zip file "/data/app/com.example-b2AaI9HdMFVibhYyMrBrNQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example-b2AaI9HdMFVibhYyMrBrNQ==/lib/x86, /system/lib, /vendor/lib]]
                      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                      at android.app.Instrumentation.newApplication(Instrumentation.java:1086)
                      at android.app.LoadedApk.makeApplication(LoadedApk.java:965)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5765) 
                      at android.app.ActivityThread.-wrap1(Unknown Source:0) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
                      at android.os.Handler.dispatchMessage(Handler.java:105) 
                      at android.os.Looper.loop(Looper.java:164) 
                      at android.app.ActivityThread.main(ActivityThread.java:6541) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
                  	Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.example-b2AaI9HdMFVibhYyMrBrNQ==/base.apk because: Failure to verify dex file '/data/app/com.example-b2AaI9HdMFVibhYyMrBrNQ==/base.apk': Bad method handle type 7
                      at dalvik.system.DexFile.openDexFileNative(Native Method)
                      at dalvik.system.DexFile.openDexFile(DexFile.java:353)
                      at dalvik.system.DexFile.<init>(DexFile.java:100)
                      at dalvik.system.DexFile.<init>(DexFile.java:74)
                      at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
                      at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
                      at dalvik.system.DexPathList.<init>(DexPathList.java:157)
                      at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
                      at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
                      at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
                      at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
                      at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
                      at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:676)
                      at android.app.LoadedApk.getClassLoader(LoadedApk.java:709)
                      at android.app.LoadedApk.getResources(LoadedApk.java:936)
                      at android.app.ContextImpl.createAppContext(ContextImpl.java:2242)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5672)
                      		... 8 more

Iv updated my gradle to use sdk 27, if i remove the dependency my app runs fine with no crash.
I am puzzled to what can be causing this?

Iv compiled and run your sample project and works fine

Info Required

  • Which version of the library do you actually use?
    4.0.1

  • Do you have the localization permission granted?

  • Are you sending parameters to the activity through the bundle?
    N/A

  • Could you describe what are the actions do you make to raise that error?
    Running app

  • Android monitor shows any log related to the library when the error is shown?

  • Any other thing that could help me to reproduce the error?

Screenshots

@CurralesDragon
Copy link
Author

CurralesDragon commented Mar 9, 2018

After looking at your sample project i noticed a difference in the gradle config from my project.
It appears adding:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

into my config fixed the error.

Don't currently understand why this fixes it, il do some research

@ferranpons
Copy link
Member

@nicwhitts it's needed if you have code with java 8 to have compatibility. For more info you could check this: https://stackoverflow.com/questions/16654951/gradle-sourcecompatibility-vs-targetcompatibility

I'm closing this issue since you found the solution. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants