Background
I wanted to update all of my dependencies before continuing with a new feature for my application. This is always a fun time. I hate coming here with posts like: "this code doesn't work" but here I am.
Problem
I narrowed the issues down to a change in my Gradle file. The app works with:
build.gradle
buildscript {
ext {
...
compose_version = '1.1.0-alpha02'
kotlin_version = '1.5.21'
hilt_version = '2.38.1'
...
build.gradle.app
...
dependencies {
...
// hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha03'
// For Robolectric tests.
testImplementation "com.google.dagger:hilt-android-testing:2.38.1"
// ...with Kotlin.
kaptTest "com.google.dagger:hilt-android-compiler:2.38.1"
implementation("androidx.hilt:hilt-work:1.0.0")
kapt("androidx.hilt:hilt-compiler:1.0.0")
// Compose UI tests
// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")
// Needed for createComposeRule, but not createAndroidComposeRule:
debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
implementation("androidx.room:room-runtime:$room_version")
annotationProcessor "androidx.room:room-compiler:$room_version"
kapt("androidx.room:room-compiler:$room_version")
implementation("androidx.room:room-ktx:$room_version")
...
But then I updated Kotlin and Compose (because the earlier version of compose is incompatible with Kotlin 1.6.0). I received some weird errors which I solved by converting kapt(...) dependencies to annotationProcessor(...) dependencies:
build.gradle
buildscript {
ext {
...
compose_version = '1.1.0-rc01'
kotlin_version = '1.6.0'
hilt_version = '2.38.1'
...
build.gradle.app
...
dependencies {
...
// hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
annotationProcessor "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha03'
// For Robolectric tests.
testImplementation "com.google.dagger:hilt-android-testing:2.38.1"
// ...with Kotlin.
kaptTest "com.google.dagger:hilt-android-compiler:2.38.1"
implementation("androidx.hilt:hilt-work:1.0.0")
annotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
// Compose UI tests
// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")
// Needed for createComposeRule, but not createAndroidComposeRule:
debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
implementation("androidx.room:room-runtime:$room_version")
annotationProcessor "androidx.room:room-compiler:$room_version"
annotationProcessor("androidx.room:room-compiler:$room_version")
implementation("androidx.room:room-ktx:$room_version")
...
and then I began getting this error. Which makes me think that there is some deeper issue with Hilt. I tried multiple (newer) Hilt versions as well including the newest 2.40.5.
2021-12-29 22:33:07.479 15168-15168/com.XXX.networkdatausage E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.XXX.networkdatausage, PID: 15168
java.lang.RuntimeException: Unable to instantiate application com.XXX.networkdatausage.NetworkUsageApplication: java.lang.ClassNotFoundException: Didn't find class "com.XXX.networkdatausage.NetworkUsageApplication" on path: DexPathList[[zip file "/data/app/com.XXX.networkdatausage-03CzYbinIiu2DMSufPHnog==/base.apk"],nativeLibraryDirectories=[/data/app/com.XXX.networkdatausage-03CzYbinIiu2DMSufPHnog==/lib/arm, /system/lib, /system/vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1138)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6298)
at android.app.ActivityThread.access$1200(ActivityThread.java:242)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7179)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.XXX.NetworkUsageApplication" on path: DexPathList[[zip file "/data/app/com.XXX.networkdatausage-03CzYbinIiu2DMSufPHnog==/base.apk"],nativeLibraryDirectories=[/data/app/com.XXX.networkdatausage-03CzYbinIiu2DMSufPHnog==/lib/arm, /system/lib, /system/vendor/lib]]
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 android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
at android.app.Instrumentation.newApplication(Instrumentation.java:1124)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1130)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6298)
at android.app.ActivityThread.access$1200(ActivityThread.java:242)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7179)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/XXX/networkdatausage/Hilt_NetworkUsageApplication;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 14 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.XXX.networkdatausage.Hilt_NetworkUsageApplication" on path: DexPathList[[zip file "/data/app/com.XXX.networkdatausage-03CzYbinIiu2DMSufPHnog==/base.apk"],nativeLibraryDirectories=[/data/app/com.XXX.networkdatausage-03CzYbinIiu2DMSufPHnog==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 17 more
Android Studio Version
Android Studio Arctic Fox | 2020.3.1 Patch 4
Question
What do I need to do to fix this? If you would like to see more of my Gradle files please let me know. Should I post this question somewhere else?
Edit
When I switch
annotationProcessor "com.google.dagger:hilt-android-compiler:$hilt_version"
to
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
I get this error (I couldn't include entire message so I just included the last two "caused by"):
Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.NoSuchMethodError: kotlinx.metadata.jvm.KotlinClassHeader.<init>(Ljava/lang/Integer;[I[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)V
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:992)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1335)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
... 34 more
Caused by: java.lang.NoSuchMethodError: kotlinx.metadata.jvm.KotlinClassHeader.<init>(Ljava/lang/Integer;[I[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)V
at dagger.internal.codegen.kotlin.KotlinMetadata.metadataOf(KotlinMetadata.java:202)
at dagger.internal.codegen.kotlin.KotlinMetadata.from(KotlinMetadata.java:187)
at dagger.internal.codegen.kotlin.KotlinMetadataFactory.create(KotlinMetadataFactory.java:56)
at dagger.internal.codegen.kotlin.KotlinMetadataUtil.isObjectClass(KotlinMetadataUtil.java:91)
at dagger.internal.codegen.kotlin.KotlinMetadataUtil.isObjectOrCompanionObjectClass(KotlinMetadataUtil.java:108)
at dagger.hilt.processor.internal.Processors.requiresModuleInstance(Processors.java:931)
at dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsProcessor.processModule(AggregatedDepsProcessor.java:169)
at dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsProcessor.processEach(AggregatedDepsProcessor.java:120)
at dagger.hilt.processor.internal.BaseProcessor.process(BaseProcessor.java:195)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:188)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980)
... 38 more
Solution
The issue was how I incorrectly handled the kapt errors after upgrading Kotlin.
I reverted all of my annotationProcessor(...) migrations back to kapt(...) and here was the issue:
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
was supposed to be:
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Related
I'm trying to implement OTP verification by phone number using firebasebut I'am getting ths error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wasali.mobile_authentication, PID: 7864
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth##20.0.1:13)
at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth##20.0.1:7)
at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(com.google.firebase:firebase-auth##20.0.1)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6276)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.wasali.mobile_authentication-1/base.apk"],nativeLibraryDirectories=[/data/app/com.wasali.mobile_authentication-1/lib/arm64, /system/lib64, /vendor/lib64, /system/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 com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth##20.0.1:13)
at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth##20.0.1:7)
at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(com.google.firebase:firebase-auth##20.0.1)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6276)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
I tried many solutions like add this dependencie but it doesn't work:
implementation androidx.browser:browser:1.2.0
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
I was facing same issue, please try following-
//import broswer(require for firebase reCaptch Verifications)
implementation 'androidx.browser:browser:1.2.0'
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
Make sure you put apply plugin: 'com.google.gms.google-services' // Google Services plugin
at top of build.gradle(app), and add a dependency in build.gradle(Project) as following-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.4' // Google Services plugin
}
}
In case you are facing error as 'Static interface methods are only supported starting with Android N' then update Java Version to 1.8 via adding those lines
in your build.gradle(Project)
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}
Happy coding!
I am currently using Retrofit 2 and Firebase services in one project. The project is working fine but when I update Retrofit 2 Library to the new version (2.9.0), gradle synced perfectly but when running the app I get this error and the app fails. Error message: Unable to get provider com.google.firebase.perf.provider.FirebasePerfProvider:java.lang.ClassNotFoundException
My dependencies in Gradle-app looks like this:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-core:17.4.2'
implementation 'com.google.firebase:firebase-messaging:20.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' //for crashlytics
implementation 'com.google.firebase:firebase-perf:19.0.7'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'me.dm7.barcodescanner:zxing:1.9'
Full error message:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fm.csfm, PID: 8717
java.lang.RuntimeException: Unable to get provider com.google.firebase.perf.provider.FirebasePerfProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.perf.provider.FirebasePerfProvider" on path: DexPathList[[zip file "/data/app/com.fm.csfm-WHtOa5E0nJ2xAlJon-1HGQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.fm.csfm-WHtOa5E0nJ2xAlJon-1HGQ==/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6288)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
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.google.firebase.perf.provider.FirebasePerfProvider" on path: DexPathList[[zip file "/data/app/com.fm.csfm-WHtOa5E0nJ2xAlJon-1HGQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.fm.csfm-WHtOa5E0nJ2xAlJon-1HGQ==/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.ActivityThread.installProvider(ActivityThread.java:6273)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
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.fm.csfm-WHtOa5E0nJ2xAlJon-1HGQ==/base.apk because: Failure to verify dex file '/data/app/com.fm.csfm-WHtOa5E0nJ2xAlJon-1HGQ==/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
Got it through!
I found that the problem was not a conflict with Firebase as I have noticed that when I update Retrofit in other projects also gives other errors. The solution was to add JAVA 8 support as follow:
In Gradle-app:
android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
This morning I decided to migrate all app to Android X to use some new feature, but I got several problems, most of it in these three layout, (activity_main.xml, app_bar_main.xml, content_main.xml)
When I run the app I got this errors
2019-03-04 12:30:18.948 28112-28112/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: www.pro_cs_is.com, PID: 28112
java.lang.RuntimeException: Unable to start activity ComponentInfo{www.pro_cs_is.com/www.pro_cs_is.com.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #2: Error inflating class CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6653)
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:821)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #2: Error inflating class CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class CoordinatorLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/base.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_dependencies_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_resources_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_0_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_1_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_2_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_3_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_4_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_5_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_6_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_7_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_8_apk.apk", zip file "/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/lib/arm64, /system/lib64, /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 android.view.LayoutInflater.createView(LayoutInflater.java:610)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:707)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:724)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:792)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:969)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:141)
at www.pro_cs_is.com.MainActivity.onCreate(MainActivity.java:67)
at android.app.Activity.performCreate(Activity.java:7098)
at android.app.Activity.performCreate(Activity.java:7089)
2019-03-04 12:30:18.949 28112-28112/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6653)
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:821)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/www.pro_cs_is.com-MQHeR58522USvJ7r2TTHzQ==/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: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:5725)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
... 6 more
build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "testApp.com"
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-messaging:17.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'com.google.code.findbugs'
})
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.google.apis:google-api-services-blogger:v3-rev57-1.23.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.j256.ormlite:ormlite-android:5.1'
implementation 'com.j256.ormlite:ormlite-core:5.1'
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.8#aar') {
transitive = true
}
implementation 'androidx.multidex:multidex:2.0.1'
// ViewModel and LiveData
dependencies {
def lifecycle_version = "2.0.0"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation 'android.arch.lifecycle:extensions:1.1.1'
// optional - ReactiveStreams support for LiveData
implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version"
// For Kotlin use lifecycle-reactivestreams-ktx
// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
}
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
about this error No original dex files found for dex location I tried the solution in this question1, question2 but not working
CTRL + Shift + F and found all CoordinatorLayout.
Then check if CoordinatorLayout elements has this signiture in xml files: androidx.coordinatorlayout.widget.CoordinatorLayout
Use this material design library and make sure all of your widgets are androidx
implementation 'com.google.android.material:material:1.1.0-alpha04'
The recyclerview and navigationView are not part of androidx material design it should be :- ( you are using older design version of recyclerview and NavigationView )
<androidx.recyclerview.widget.RecyclerView
.....
.....
&&
<com.google.android.material.navigation.NavigationView
.....
.....
Edit
Make sure you upgrade every widget to androidx .
The appbar widget should be
<com.google.android.material.appbar.AppBarLayout
I am using android's data binding library for views in a library project
i have added the following line in my root gradle file
classpath 'com.android.databinding:dataBinder:1.0-rc1'
and have enabled the dataBinding as given below in module's gradle file
apply plugin: 'com.android.databinding'
...
...
android {
....
dataBinding {
enabled = true
}
}
i have enabled the multiDex in my library project
as well as in the host app which is using this library
but i get this stack trace of error while launching the library's activity
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBinderMapper;
at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
at sdk.ui.activities.MyActivity.onCreate(MyActivity.java:76)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.databinding.DataBinderMapper" on path: DexPathList[[zip file "/data/app/testApp.dev-1/base.apk"],nativeLibraryDirectories=[/data/app/testApp.dev-1/lib/arm64, /data/app/testApp.dev-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
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.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
at sdk.ui.activities.MyActivity.onCreate(MyActivity.java:76)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Suppressed: java.lang.ClassNotFoundException: android.databinding.DataBinderMapper
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Make sure that ALL your modules that use DataBinding have it enabled. This was the reason I got that exception.
android {
....
dataBinding {
enabled = true
}
}
finally i was able to solve this issue.
It seems there was a conflict between apt version of the app and library modules.
upgraded the apt version in the app to
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Besides adding the following to build.gradle:
android {
dataBinding {
enabled = true
}
}
I also have to add the following dependency:
dependencies {
kapt 'com.android.databinding:compiler:3.1.4'
}
Best guess. Get rid of android-apt
And if there are libraries using apt
Instead of apt 'lt.mdm.sdd:myLib:1.5.1' use
annotationProcessor 'lt.mdm.sdd:myLib:1.5.1'.
I'm not sure if this will help you, and i have no idea if library it self should be changed.
It helped me (i was using androidannotations.org older version with apt) at least.
Update
And i have no idea why you apply plugin: 'com.android.databinding'? It works without it as well.
I had the same problem after performing the migration androdx. I tried all the above methods but not resolved. I suddenly found that I used
com.android.tools.build:gradle version is 3.3. I update it to 3.5. Problem is solved.
project build.gradle:
classpath 'com.android.tools.build:gradle:3.3.0'
Update to
classpath 'com.android.tools.build:gradle:3.5.0'
Redo the migration.
classpath 'com.android.databinding:dataBinder:1.0-rc1'
apply plugin: 'com.android.databinding'
Remove that lib. from gradle.
I had the same problem, but I solved it removing
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
from the global build.gradle and removing
apply plugin: 'android-apt'
from the local build.gradle, then it worked like a charm.
It seems it was a mixed problem with Butterknife too. Pretty weird.
The new way of adding DataBinding is by adding on the build.gradle of all your modules:
android {
...
buildFeatures {
dataBinding true
}
}
Don't forget to add also the kotlin-kapt plugin at the top:
plugins {
...
id 'kotlin-kapt'
}
Get inspiration from #Bolein95 say.Because it depend on a library that does not support androidx(no setting databinding=true),Written by a colleague who has left.I copy a few necessary files from his github repo, it work!
I'm getting class not found exception in my Android library (aar) when GoogleApiAvailability is called.
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GoogleApiAvailability" on path: DexPathList[[zip file "/data/app/com.myunityplugin.PushNotifications-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myunityplugin.PushNotifications-1/lib/arm, /vendor/lib, /system/lib]]
The error is self-explanatory, but I'm not sure what I'm doing wrong. I'm pretty new to gradle and AndroidStudio.
I have the following under dependencies within my gradle.build:
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
I think the problem is that the play-services library needs to be included in the aar, and compile doesn't do that. I tried using 'runtime' but I get "gradle dsl runtime not found".
Questions:
Is this an issue where I need to include the play-services library in my aar, and how do I accomplish that? (if not, how do I address this problem)
Do I need to specify play-services or does play-services-gcm suffice?
Error Info / Setup
Line causing the error
GoogleApiAvailability ServiceAvailability = GoogleApiAvailability.getInstance();
Exception:
05-23 05:38:48.221 28055-28055/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myunityplugin.PushNotifications, PID: 28055
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GoogleApiAvailability;
at com.myplugin.unitynotification.GCM.GCM.checkPlayServices(GCM.java:33)
at com.myplugin.unitynotification.GCM.MainActivity.onCreate(MainActivity.java:80)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6897)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GoogleApiAvailability" on path: DexPathList[[zip file "/data/app/com.myunityplugin.PushNotifications-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myunityplugin.PushNotifications-1/lib/arm, /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 com.myplugin.unitynotification.GCM.GCM.checkPlayServices(GCM.java:33)
at com.myplugin.unitynotification.GCM.MainActivity.onCreate(MainActivity.java:80)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3263)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1687)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6897)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
App Level build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
provided files('lib-not-include/classes.jar')
}
Project level gradle.build
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The aar file doesn't contain the nested (or transitive) dependencies and doesn't have a pom file which describes the dependencies used by the library.
It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.
You should use a maven repository (you have to publish the library in a private or public maven repo), you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.