NoClassDefFoundError at opening Dynamic Module - android

Suppose I have created an Android project AwesomeApp. Then I need to add chatting functionality to this App. So that, I have created another project to build an SDK for chatting. The output of my chat SDK are 4 aar files. These aar files contain another chat SDK of Applozic.
Then I have successfully integrated 4 aar files to my AwesomeApp and everything is going fine. But the aar files are too large. So I have decided to use Android's new dynamic delivery feature.
To do so, I have created new project. In manifest file I've mention application name like this android:name="com.google.android.play.core.splitcompat.SplitCompatApplication". In this project I have created a dynamic module chat-module. Inside this dynamic module I have created an activity DynamicActivity and added those 4 aar files. From DynamicActivity I call the chat feature (of aar file) by clicking on an icon.
I can successfully download the chat-module and open DynamicActivity of chat-module dynamic module. But when I click on the icon of DynamicActivity to open/initialize chat feature - the app has crashed. Crash report:
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:6304)
at android.view.View$PerformClick.run(View.java:24803)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6304) 
at android.view.View$PerformClick.run(View.java:24803) 
at android.os.Handler.handleCallback(Handler.java:794) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:6651) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/applozic/mobicomkit/Applozic;
at com.example.chatapp.utility.ChitChat.initialize(ChitChat.java:83)
at com.example.chatapp_dynamic_module.DynamicActivity.startSecondPerson(DynamicActivity.java:53)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) 
at android.view.View.performClick(View.java:6304) 
at android.view.View$PerformClick.run(View.java:24803) 
at android.os.Handler.handleCallback(Handler.java:794) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:6651) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.applozic.mobicomkit.Applozic" on path: DexPathList[[zip file "/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/base.apk", zip file "/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.en.apk", zip file "/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.xhdpi.apk", zip file "/data/user/0/com.example.applab/files/splitcompat/1/verified-splits/chitchat_dynamic_module.apk"],nativeLibraryDirectories=[/data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.example.chatapp.utility.ChitChat.initialize(ChitChat.java:83) 
at com.example.chatapp_dynamic_module.DynamicActivity.startSecondPerson(DynamicActivity.java:53) 
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) 
at android.view.View.performClick(View.java:6304) 
at android.view.View$PerformClick.run(View.java:24803) 
at android.os.Handler.handleCallback(Handler.java:794) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:6651) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824) 
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.en.apk
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.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:695)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:729)
at android.app.LoadedApk.getResources(LoadedApk.java:956)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2282)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
at android.os.Handler.dispatchMessage(Handler.java:106)
... 5 more
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.applab-aoTGwb4UiExHn2UP-1ioGA==/split_config.xhdpi.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
2019-10-13 12:32:06.538 25730-25730/com.example.applab E/AndroidRuntime: 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.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:695)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:729)
at android.app.LoadedApk.getResources(LoadedApk.java:956)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2282)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
at android.os.Handler.dispatchMessage(Handler.java:106)
... 5 more
Please help me to resolve the issue.

Related

Unity 2019 - Android - NoClassDefFoundError with custom library and Google Play Service dependencies

I'm working on an App for Android which uses a custom library. This library needs the
implementation 'com.google.android.gms:play-services-ads:17.1.2'
I generate a plugin for unity with Android Studio and build the App. Everything works fine until I start using functions of the custom library. The app crashes with the following error message. What do I have to do to fix this NoClassDefFoundError for the Google Play Service stuff. I'm really stuck.
Process: com.example.app, PID: 10230
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;
at com.customLib.lib.o.a(SourceFile:36)
at com.customLib.lib.i0.<init>(SourceFile:81)
at com.customLib.lib.e0.<init>(SourceFile:10)
at com.customLib.lib.u.a(SourceFile:17)
at com.customLib.lib.s$h.a(SourceFile:1)
at com.customLib.lib.p.run(SourceFile:1)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.identifier.AdvertisingIdClient" on path: DexPathList[[zip file "/data/app/com.example.app-DMDw0weJE1AN-hQFZpfcWA==/base.apk", zip file "/data/app/com.example.app-DMDw0weJE1AN-hQFZpfcWA==/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/app/com.example.app-DMDw0weJE1AN-hQFZpfcWA==/lib/arm64, /data/app/com.example.app-DMDw0weJE1AN-hQFZpfcWA==/base.apk!/lib/arm64-v8a, /data/app/com.example.app-DMDw0weJE1AN-hQFZpfcWA==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
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 com.customLib.lib.o.a(SourceFile:36)
at com.customLib.lib.i0.<init>(SourceFile:81)
at com.customLib.lib.e0.<init>(SourceFile:10)
at com.customLib.lib.u.a(SourceFile:17)
at com.customLib.lib.s$h.a(SourceFile:1)
at com.customLib.lib.p.run(SourceFile:1)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/com.example.app-DMDw0weJE1AN-hQFZpfcWA==/split_config.arm64_v8a.apk
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:678)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:711)
at android.app.LoadedApk.getResources(LoadedApk.java:944)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2303)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5943)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
I'm working with Unity 2019.4
Thanks a lot for your help!
Cheers Stephan

How to solve a problem which causes app to crash when new dependency is added to gradle?

I am trying to integrate paynow api to my application, I have not done much, so far I have just added this dependance to gradle: implementation 'zw.co.paynow:java-sdk:1.1.1'
Supprisingly the app crashes, if I remove it the app does not crash, so adding it is crashing my app. So my question is, what could be missing that causes this crash?
logcat:
2021-06-11 19:32:31.825 25519-25519/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2021-06-11 19:32:31.829 25519-25519/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
2021-06-11 19:32:32.655 25519-25519/com.coin.cryptobase E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.coin.cryptobase, PID: 25519
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.coin.cryptobase/com.coin.cryptobase.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.coin.cryptobase.MainActivity" on path: DexPathList[[zip file "/data/app/com.coin.cryptobase-faku93JC1CyPtG_PsAGmrA==/base.apk"],nativeLibraryDirectories=[/data/app/com.coin.cryptobase-faku93JC1CyPtG_PsAGmrA==/lib/arm, /system/lib, /system/vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2841)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6942)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.coin.cryptobase.MainActivity" on path: DexPathList[[zip file "/data/app/com.coin.cryptobase-faku93JC1CyPtG_PsAGmrA==/base.apk"],nativeLibraryDirectories=[/data/app/com.coin.cryptobase-faku93JC1CyPtG_PsAGmrA==/lib/arm, /system/lib, /system/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.newActivity(Instrumentation.java:1181)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6942) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 
Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.coin.cryptobase-faku93JC1CyPtG_PsAGmrA==/base.apk because: Failure to verify dex file '/data/app/com.coin.cryptobase-faku93JC1CyPtG_PsAGmrA==/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:678)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:711)
at android.app.LoadedApk.getResources(LoadedApk.java:944)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2303)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5943)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
... 6 more
First clean the project, then invalidate android studio from File -> Invalidate Caches / Restart.. -> Invalidate and Restart.

Failed to include Retrofit version > 2.6 in Project

I try to include Retrofit with Gson converter in my project.
Without the changes in the gradle file, everything works. When I add the dependencies
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
to my gradle file, the project still compiles and even installs the app, but it crashes with this error:
2020-07-10 21:14:02.261 9083-9083/com.testproject.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.testproject.app, PID: 9083
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.testproject.app/com.testproject.app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.testproject.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.testproject.app-Au1uLD6rtjGrZa2PoCEKZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.testproject.app-Au1uLD6rtjGrZa2PoCEKZA==/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
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.testproject.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.testproject.app-Au1uLD6rtjGrZa2PoCEKZA==/base.apk"],nativeLibraryDirectories=[/data/app/com.testproject.app-Au1uLD6rtjGrZa2PoCEKZA==/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.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
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.testproject.app-Au1uLD6rtjGrZa2PoCEKZA==/base.apk because: Failure to verify dex file '/data/app/com.testproject.app-Au1uLD6rtjGrZa2PoCEKZA==/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)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
... 6 more
Edit:
Found out that it works with Retrofit 2.6.0, but not with greater versions.
You only need the Square GSON dependency - remove the GSON dependency from Google. Should read like this:
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

RxJava 3.0.0 crashes a default Empty Activity project?

I create a new project in Android Studio 3.6 with default Empty Activity.
By just adding this to my gradle, sync and compile,
implementation "io.reactivex.rxjava3:rxjava:3.0.0"
The example app fail to even start, and crash as below
2020-03-09 21:47:15.448 12193-12193/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.elyeproj.myapplication, PID: 12193
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.elyeproj.myapplication/com.elyeproj.myapplication.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.elyeproj.myapplication.MainActivity" on path: DexPathList[[zip file "/data/app/com.elyeproj.myapplication-DiXzq-aNWvgVfrGsWCptJQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.elyeproj.myapplication-DiXzq-aNWvgVfrGsWCptJQ==/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
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.elyeproj.myapplication.MainActivity" on path: DexPathList[[zip file "/data/app/com.elyeproj.myapplication-DiXzq-aNWvgVfrGsWCptJQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.elyeproj.myapplication-DiXzq-aNWvgVfrGsWCptJQ==/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.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
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.elyeproj.myapplication-DiXzq-aNWvgVfrGsWCptJQ==/base.apk because: Failure to verify dex file '/data/app/com.elyeproj.myapplication-DiXzq-aNWvgVfrGsWCptJQ==/base.apk': Bad method handle type 8
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)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
... 6 more
Is this expected (i.e. I miss something), or is it a bug?
Note, adding implementation "io.reactivex.rxjava2:rxjava:2.2.18" compiles fine.
You need to use Android Studio 4.0 or newer (and more importantly, AGP 4.0 or newer) to use RxJava3 in Android projects, because that is what adds the new desugaring capabilities that RxJava3 relies on.

Firebird and Android JDBC Driver

have problem with Firebird. I have never work with DB. DB on server firebird 1.5.
Add lib: firebird-full-2.2.4 to libs folder
Add this to Gradle: implementation fileTree('libs')
Add this to MainActivity:
Class.forName("org.firebirdsql.jdbc.FBDriver")
val connection = DriverManager.getConnection(
"jdbc:firebirdsql://jdbc:firebirdsql:193.###.###.13/3050:Scool",
"###", "###")
connection.close()
After start I have this:
E/AndroidRuntime: FATAL
EXCEPTION: main
Process: success.kneu, PID: 12219
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/resource/Referenceable;
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at success.kneu.LoginActivity$onCreate$1.onClick(LoginActivity.kt:48)
at android.view.View.performClick(View.java:5647)
at android.view.View$PerformClick.run(View.java:22465)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6238)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.ClassNotFoundException: javax.resource.Referenceable
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:400) 
at java.lang.Class.forName(Class.java:326) 
at success.kneu.LoginActivity$onCreate$1.onClick(LoginActivity.kt:48) 
at android.view.View.performClick(View.java:5647) 
at android.view.View$PerformClick.run(View.java:22465) 
at android.os.Handler.handleCallback(Handler.java:754) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:163) 
at android.app.ActivityThread.main(ActivityThread.java:6238) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/naming/Referenceable;
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:400) 
at java.lang.Class.forName(Class.java:326) 
at success.kneu.LoginActivity$onCreate$1.onClick(LoginActivity.kt:48) 
at android.view.View.performClick(View.java:5647) 
at android.view.View$PerformClick.run(View.java:22465) 
at android.os.Handler.handleCallback(Handler.java:754) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:163) 
at android.app.ActivityThread.main(ActivityThread.java:6238) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.naming.Referenceable" on path: DexPathList[[zip file
"/data/app/success.kneu-1/base.apk", zip file
"/data/app/success.kneu-1/split_lib_dependencies_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_0_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_1_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_2_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_3_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_4_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_5_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_6_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_7_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_8_apk.apk", zip file
"/data/app/success.kneu-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/success.kneu-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 java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:400) 
at java.lang.Class.forName(Class.java:326) 
at success.kneu.LoginActivity$onCreate$1.onClick(LoginActivity.kt:48) 
at android.view.View.performClick(View.java:5647) 
at android.view.View$PerformClick.run(View.java:22465) 
at android.os.Handler.handleCallback(Handler.java:754) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:163) 
at android.app.ActivityThread.main(ActivityThread.java:6238) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 
2019-07-14 17:37:03.815 12219-12219/? I/Process: Sending signal. PID:
12219 SIG: 9
Jaybird, the Firebird JDBC driver, does not work on Android. There is an Android port of Jaybird, but it is not maintained by the Jaybird team.
The error itself indicates a problem with loading the connector-api because of missing JNDI classes like javax.naming.Referenceable in Android. This would indicate that you are trying to use the normal Jaybird and not the Android port of Jaybird.
Try and replace your Jaybird dependency with one from the Android port.
Be aware though that in general you should not use JDBC drivers to connect to a database from Android. See also JDBC vs Web Service for Android.

Categories

Resources