Activity in dynamic feature not found(ClassNotFound) - android

done:
generate a release a.abb
use bundletool to convert a.abb to a.apks.
deploy it to device.
problem:
the activity in dynamic feature no found.(but in debug, it's ok)
2019-02-25 20:48:58.429 11164-11164/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.demo.yang.myapplication, PID: 11164
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.demo.yang.myapplication/com.demo.yang.feature.TestActivity}: java.lang.ClassNotFoundException: Didn't find class "com.demo.yang.feature.TestActivity" on path: DexPathList[[zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/base.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.en.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.es.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ja.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ko.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.pt.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ru.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.vi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.xxhdpi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.zh.apk"],nativeLibraryDirectories=[/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
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:6938)
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.demo.yang.feature.TestActivity" on path: DexPathList[[zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/base.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.en.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.es.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ja.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ko.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.pt.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.ru.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.vi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.xxhdpi.apk", zip file "/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/split_config.zh.apk"],nativeLibraryDirectories=[/data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/lib/arm64, /system/lib64, /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 android.app.Instrumentation.newActivity(Instrumentation.java:1180)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2829)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030) 
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:6938) 
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: No original dex files found for dex location (arm64) /data/app/com.demo.yang.myapplication-mTCYObuADWrZE6proGE_tA==/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)

The fact that the class is found in debug but not in release suggests that it's possibly an issue with your proguard configuration (since Proguard is usually applied only on release builds).
Make sure you have
-keep public class * extends android.app.Activity
in your proguard file to ensure that the Activities are not obfuscated.

Please add this to your build.gradle at dynamic feature you create.
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

What worked for me was: remove all the tags <application> from the dynamic features' AndroidManifest and reunite all the Activities declarations on the application's AndroidManifest.
And before that I follow these migrations steps

I faced and fixed this issue. This problem arises, when you are not setting multiDexEnabled option correctly in your base build.gradle (app level) & the project itself.
defaultConfig {
...
multiDexEnabled true
}
And in dependencies
dependencies{
....
implementation "androidx.multidex:multidex:$multidex_version"
}
And you can extend your application class from MultiDexApplication
class YOUR_APPLICATION_CLASS : MultiDexApplication() {
// Rest of your code
}
In base app Manifest mention above application class like:
<application
android:name=".YOUR_APPLICATION_CLASS"
...
</application>
I paste less code for brevity.

Related

Failed resolution of: Landroidx/lifecycle/viewmodel/CreationExtras$Key; in Android Library module UI Test

Description
I'm trying to run an Android UI Test from a module, :mylibrary, that applies the com.android.library plugin. Right now, all of our Android UI tests are in our :app which is a com.android.application module. Also, the :app application module depends on the :mylibrary android library module. (The following diagram is an overly simplified representation of our dependency graph.)
When I introduce an Android UI Test in an android library module and run, I get the following error:
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.viewmodel.CreationExtras$Key" on path: DexPathList[[zip file "/data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/base.apk"],nativeLibraryDirectories=[/data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/lib/arm64, /data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
This happens whether the UI tests are simple instrumented tests (annotated with #RunWith(AndroidJUnit4::class)) or if the test is a #HiltAndroidTest.
What I've Tried
Since this looks like a dexing issue, I've tried adding
debug {
minifyEnabled false
}
and I've tried filtering the class in question in proguard:
-keep class androidx.lifecycle.** { *; }
I've also tried adding the specific dependency to the module:
dependencies {
implementation libs.androidx.lifecycle.viewModel
}
I've also tried adding
-keep class androidx.lifecycle.** { *; }
to multidex-config.pro file as explained in the keeping multidex properties section of Android Developer documentation.
Stacktrace
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.viewmodel.CreationExtras$Key" on path: DexPathList[[zip file "/data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/base.apk"],nativeLibraryDirectories=[/data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/lib/arm64, /data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 23 more
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/viewmodel/CreationExtras$Key;
at androidx.lifecycle.SavedStateHandleSupport.enableSavedStateHandles(Unknown Source:0)
at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:305)
at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:108)
at androidx.appcompat.app.AppCompatActivity.<init>(AppCompatActivity.java:94)
at com.example.ivan.MyLibraryActivity.<init>(MyLibraryActivity.kt:6)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
at android.app.Instrumentation.newActivity(Instrumentation.java:1285)
at androidx.test.runner.MonitoringInstrumentation.newActivity(MonitoringInstrumentation.java:817)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3578)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3842)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.viewmodel.CreationExtras$Key" on path: DexPathList[[zip file "/data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/base.apk"],nativeLibraryDirectories=[/data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/lib/arm64, /data/app/~~IQ9A0iTcN9ysP1ynYkle2w==/com.example.ivan.test-EKcv8pjnvziFFyouy7OVag==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 23 more

AdMob causing: unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException

Im trying to implement adMob but my app isn't launching and providing the following error:
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:7369)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access$1400(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
at android.app.ActivityThread.installProvider(ActivityThread.java:7353)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826) 
at android.app.ActivityThread.access$1400(ActivityThread.java:267) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:237) 
at android.app.ActivityThread.main(ActivityThread.java:7762) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047) 
Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk because: Bad encoded_array value: Failure to verify dex file '/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk': Bad encoded_value method type size 7
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:365)
at dalvik.system.DexFile.<init>(DexFile.java:107)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:892)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:991)
at android.app.LoadedApk.getResources(LoadedApk.java:1248)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2614)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2606)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6724)
... 8 more
I searched for this problem and all of the solutions, like this, are saying you now need to provide the App ID supplied from adMob in the manifest. I have tripled checked this and the correct app ID is provided in the manifest under meta-data tags as you can see here:
I've been following this official guide and went over it twice, but I am still getting this error.
I am also using a dedicated test ad unit ID for Android banners, so I don't think that is the problem.
What else could be causing this?
I got a similar error and this solved it.
In biuld.gradle (Module)
android {
...
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}

After changing the version to Androidx, it does not become mqtt connect

After changing version to Androidx and can not connect to mqtt server.
It worked well in other versions than Androidx.
Is this a version problem?
My source code and build information is on the link-> I added it when I made the project. AndroidX Artifact has not been mqt communication since then. What is the problem?
My error Logs↓
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.adfdffffaaaaaaa, PID: 28371
java.lang.NoClassDefFoundError: Failed resolution of:
Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
at
org.eclipse.paho.android.service.MqttAndroidClient.registerReceiver(MqttAndroidClient.java:450)
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:428)
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:358)
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:313)
at com.example.adfdffffaaaaaaa.MqttKt.connect(Mqtt.kt:15)
at com.example.adfdffffaaaaaaa.MainActivity.onCreate(MainActivity.kt:12)
at android.app.Activity.performCreate(Activity.java:7159)
at android.app.Activity.performCreate(Activity.java:7150)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3001)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3156)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:205)
at android.app.ActivityThread.main(ActivityThread.java:6993)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"androidx.localbroadcastmanager.content.LocalBroadcastManager" on path: DexPathList[[zip file
"/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/base.apk", zip file
"/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_dependencies_apk.apk", zip
file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_resources_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_0_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_1_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_2_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_3_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_4_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_5_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_6_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_7_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_8_apk.apk",
zip file "/data/app/com.example.adfdffffaaaaaaa-
anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=
[/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/lib/arm64, /system/lib64,
/system/product/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at
org.eclipse.paho.android.service.MqttAndroidClient.registerReceiver(MqttAndroidClient.java:450) 
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:428) 
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:358) 
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:313) 
at com.example.adfdffffaaaaaaa.MqttKt.connect(Mqtt.kt:15) 
at com.example.adfdffffaaaaaaa.MainActivity.onCreate(MainActivity.kt:12) 
at android.app.Activity.performCreate(Activity.java:7159) 
at android.app.Activity.performCreate(Activity.java:7150) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3001) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3156) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
at
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:205) 
at android.app.ActivityThread.main(ActivityThread.java:6993) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884) 
Suppressed: java.io.IOException: No original dex files found for dex location
/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
E/AndroidRuntime: at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
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:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:733)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:816)
at android.app.LoadedApk.getResources(LoadedApk.java:1038)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2391)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6040)
at android.app.ActivityThread.access$1100(ActivityThread.java:208)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
... 6 more
Try setting android.enableJetifier=true in gradle.properties file. If that doesn't work, try adding implementation 'androidx.legacy:legacy-support-v4:1.0.0' to build.grade.
This problem has been solved before in the next links, I highly recommend checking them out, specially 420:
https://github.com/eclipse/paho.mqtt.android/issues/321
https://github.com/eclipse/paho.mqtt.android/issues/420
I had the same problem.
I solved it. my solution:
Add this dependency to the build.gradle(:app)
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Use these implementations for paho mqtt in the build.gradle(:app)
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
Add these permissions to the manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
add this line to gradle.properties
android.enableJetifier=true
It worked for me. I hope works for you too.

No original dex files found for dex location

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nnroh.debtmanager, PID: 23433
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nnroh.debtmanager/com.example.nnroh.debtmanager.AddPersonActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class layout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class layout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class layout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.layout" on path: DexPathList[[zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/base.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_resources_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/lib/x86, /system/lib, /vendor/lib]]
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 android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:703)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.nnroh.debtmanager.AddPersonActivity.onCreate(AddPersonActivity.java:39)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.nnroh.debtmanager-eZJs9JyPFQcK5hHTFcCewQ==/split_lib_resources_apk.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:693)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:727)
at android.app.LoadedApk.getResources(LoadedApk.java:954)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2270)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
... 6 more
Below I'm listing possible solutions,
try this steps one by one:
1 Delete app on device and Clean Project
2 Disable minifyEnabled in debug mode
go to build.gradle(Module: app) in debug block and disable minifyEnabled:
buildTypes {
debug {
minifyEnabled false
}
}
3 Setting dataBinding to true in application's gradle file
In my case, I was including another layout
<include layout="#layout/attached_layout" />
to my activity's layout and this solved it.
android {
...
...
...
dataBinding {
enabled = true
}
}
4 Check the relative path of your activities in manifest
eg:
<activity android:name="com.pathToClass.MyActivity"
5 Check the package names in your custom views
<com.pathToClass.MyCustomView
android:id="#+id/myview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
6 Try disabling pre-dexing in the app build.gradle:
dexOptions {
preDexLibraries false
}
7 Disable Instant Run
Go to File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run
8 Try MultiDexApplication
Add this to build.gradle(Module:app)
android {
defaultConfig {
...
multiDexEnabled true
}
dependencies {
...
implementation 'androidx.multidex:multidex:2.0.1'
}
}
if you are using application class you have to extend it with MultiDexApplication instead of Application and add it to AndroidManifest.xml
<application
android:name="com.myPackageName.MyApplication"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
else add MultiDexApplication class path from library as name
<application
android:name="androidx.multidex.MultiDexApplication"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
9 Proguard obfuscation
Looks like the class is loaded by reflection, but your proguard file doesn't prevent that class from being obfuscated
Reference : http://www.tousu.in/qa/?qa=1116606/android-no-original-dex-files-found-for-dex-location
try using this code in the manifest.xml inside the application tag.
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

How can my library import another library in Android Studio?

I am starting with libraries in Android, and I have managed to import a library in my app in this way:
add the .aar file in the /libs folder
add in build.gradle:
repositories{
flatDir {
dirs'libs'
}
dependencies {
...
compile(name:'mylibrary1',ext:'aar')
}
This works fine, but I made mylibrary2 and repeated steps 1 and 2 in mylibrary1, so now mylibrary1 could use mylibrary2.
In summary I want my app to import mylibrary1 and mylibrary1 to import mylibrary2.
The problem is in my app when I call a method from mylibrary2 I get an exception: java.lang.NoClassDefFoundError, I hope someone can help me
Here is the stackstrace in case it helps:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ar.com.tally.myapplication, PID: 30197
java.lang.NoClassDefFoundError: Failed resolution of: Lar/com/tally/mylibrary2/Class2;
at ar.com.tally.mylibrary1.Class1.get1(Class1.java:10)
at ar.com.tally.myapplication.MainActivity$1.onClick(MainActivity.java:28)
at android.view.View.performClick(View.java:5076)
at android.view.View$PerformClick.run(View.java:20279)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
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:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.ClassNotFoundException: Didn't find class "ar.com.tally.mylibrary2.Class2" on path: DexPathList[[dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-support-annotations-23.2.1_d668123607e57c7aa4406ba98a4276e21606428b-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-internal_impl-23.2.1_eca880fd3aaa2f093d820f9d7b8841aa1fa00b4f-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-intermediates-exploded-aar-mylibrary1_7763b008eb2396101d055fb29b3e03d5ee273add-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.2.1_5e6bcbbe4699b2a562a7ba7b6349f8bbfbef9fb4-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-support-v4-23.2.1_c564c185a6a1edef108674e96bf4712114e0c95a-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-recyclerview-v7-23.2.1_a1ec4cea5854a30b896e5f639d2fd95cd214b2b1-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-design-23.2.1_2c4b9902e86719e2bd0652ddfba695894bed0a47-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.2.1_01059d3db947a24736ebcedd233fd40b734ccf3e-classes.dex", dex file "/data/data/ar.com.tally.myapplication/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.2.1_69d3f470bac3bccd2f54179c6363fce8b9091976-classes.dex"],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at ar.com.tally.mylibrary1.Class1.get1(Class1.java:10) 
at ar.com.tally.myapplication.MainActivity$1.onClick(MainActivity.java:28) 
at android.view.View.performClick(View.java:5076) 
at android.view.View$PerformClick.run(View.java:20279) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5910) 
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:1405) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "ar.com.tally.mylibrary2.Class2" on path: DexPathList[[zip file "/data/app/ar.com.tally.myapplication-1
So when you made mylibrary2 you changed mylibrary1 also so you need to replace both aars with the new ones clean and build again.
However if you have those libs in the same project as modules i recommend that you import them as projects instead of coping manually.
compile project(':mylibrary1')
compile project(':mylibrary2')
or if in different projects as in this case you can add mavenLocal() in repositories:
repositories {
mavenLocal()
...
}
and in your lib projects you can add the maven plugin:
apply plugin: 'maven'
then you need to call:
gradle install
which will install the libs in your local maven repo. so you don't need to copy them manually

Categories

Resources