I have an Android application I am building and would like to use the fragment-testing libraries to test some fragments in isolation. However, I am struggling to get the tests to execute:
2019-12-09 13:57:03.255 22352-22352/net.redlightning.solo E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.redlightning.solo, PID: 22352
java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{net.redlightning.solo.test/androidx.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/net.redlightning.solo.test-IhE3r3tw8UMYiQVbxTUcKw==/base.apk", zip file "/data/app/net.redlightning.solo-OBV060XuIVKmHuPoKbpynw==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system/product/lib64]]
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6395)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.AndroidJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/net.redlightning.solo.test-IhE3r3tw8UMYiQVbxTUcKw==/base.apk", zip file "/data/app/net.redlightning.solo-OBV060XuIVKmHuPoKbpynw==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system/product/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.ActivityThread.handleBindApplication(ActivityThread.java:6391)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/test/runner/MonitoringInstrumentation;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 10 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.test.runner.MonitoringInstrumentation" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/net.redlightning.solo.test-IhE3r3tw8UMYiQVbxTUcKw==/base.apk", zip file "/data/app/net.redlightning.solo-OBV060XuIVKmHuPoKbpynw==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system/product/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)
... 13 more
Here is my app's gradle.build file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "net.redlightning.solo"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
kapt {
useBuildCache = false
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core:1.1.0'
implementation 'androidx.fragment:fragment:1.2.0-rc03'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.6.2'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.github.deano2390:MaterialShowcaseView:1.3.4'
implementation 'com.github.zafarkhaja:java-semver:0.9.0'
implementation 'com.jcraft.jsch:com.springsource.com.jcraft.jsch:0.1.41'
implementation 'com.mixpanel.android:mixpanel-android:5.6.6'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.squareup.okio:okio:2.4.1'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.2.2'
implementation 'io.dronefleet.mavlink:mavlink:1.1.5'
implementation 'me.grantland:autofittextview:0.2.1'
implementation 'org.mp4parser:isoparser:1.9.41'
implementation 'pl.tajchert:waitingdots:0.2.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-rc03'
}
apply plugin: 'com.google.gms.google-services'
And here is the test class (simplified), located in androidTest:
package net.redlightning.solo.fragment
import android.content.Context
import android.location.Location
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.Assert.assertNotNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
#RunWith(AndroidJUnit4::class)
class PlanningWidgetFragmentTest {
private var instrumentationContext: Context? = null
#Before
fun setUp() {
instrumentationContext = InstrumentationRegistry.getInstrumentation().targetContext
}
#Test
fun fetchWeatherInformationRequest() {
val location = Location("flp")
location.latitude = 43.073051
location.longitude = -89.401230
location.altitude = 266.0
location.bearing = 0.0f
val scenario = launchFragmentInContainer<PlanningWidgetFragment>()
scenario.onFragment {
val result = it.fetchWeatherInformationRequest(location)
assertNotNull(result)
}
}
I have tried with and without the #RunWith(AndroidJUnit4::class) annotation on the test class, I have tried with 1.2.0-rc03 and 1.1.0 versions of androidx.fragment:fragment-testing (and androidx.fragment:fragment so they match) in gradle, I've tried having the import be in debugImplmentation (as the docs and articles from a year ago describe), implementation, and androidTestImplementation. Nothing seems to work.
It is likely worth noting that if I remove fragment-testing from the project, and comment out the lines using it in the test (so it just builds a location it doesn't use) the test runs to completion just fine.
What is the correct setup to allow me to use androidx.fragment:fragment-testing?
Related
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
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.appium_new"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
packagingOptions {
exclude 'lang-708-input.txt'
exclude 'java.policy'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('src/libs/byte-buddy-1.8.15.jar')
implementation files('src/libs/commons-exec-1.3.jar')
implementation files('src/libs/commons-lang3-3.9.jar')
implementation files('src/libs/commons-lang3-3.9-sources.jar')
implementation files('src/libs/commons-lang3-3.9-test-sources.jar')
implementation files('src/libs/commons-lang3-3.9-tests.jar')
implementation files('src/libs/guava-25.0-jre.jar')
implementation files('src/libs/java-client-7.3.0.jar')
implementation files('src/libs/okhttp-3.11.0.jar')
implementation files('src/libs/okio-1.14.0.jar')
implementation files('src/libs/selenium-server-standalone-3.141.59.jar')
}
After adding the last library i.e. implementation files('src/libs/selenium-server-standalone-3.141.59.jar') its show below error, if I remove this library then it work fine
2019-11-13 18:05:44.994 12737-12744/? E/com.appium_new: Failed to send DDMS packet REAQ to debugger (-1 of 20): Broken pipe
2019-11-13 18:05:45.587 12737-12737/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.appium_new, PID: 12737
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appium_new/com.appium_new.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.appium_new.MainActivity" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/lib/x86, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2843)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
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:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
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:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.appium_new.MainActivity" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/lib/x86, /system/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.instantiateActivity(AppComponentFactory.java:69)
at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
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:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
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:858)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 15 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/base.apk"],nativeLibraryDirectories=[/data/app/com.appium_new-0MtEr8TXu2cbQ_krT1jqPg==/lib/x86, /system/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)
... 18 more
After adding library gradle haven't synced properly so it's showing the error, "Didn't find class '.MainActivity' ":
The main problem is some gradle files have same internal files like:-
implementation files('src/libs/okhttp-3.11.0.jar')
implementation files('src/libs/okio-1.14.0.jar')
or
implementation files('src/libs/commons-lang3-3.9.jar')
implementation files('src/libs/commons-lang3-3.9-sources.jar')
implementation files('src/libs/commons-lang3-3.9-tests.jar')
so it's not syncing successfully ,
Or second option is to use gradle versions like
implementation("com.squareup.okhttp3:okhttp:4.2.2")
implementation 'com.github.apache:commons-lang:LANG_3_8_1_RC1'
and put version according to your need...
The main problem is ClassNotFoundException so check on this link there have given many solution. use it and see what work with your project.
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 getting this error:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;
Here is the full output:
2018-11-09 18:33:22.546 24224-24224/com.test.notes.notes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.notes.notes, PID: 24224
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.android.gms.internal.firebase-firestore.zzkj.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;
at com.google.android.gms.internal.firebase-firestore.zzfu.zzd(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzeg.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcj.zza(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcl.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.firebase-firestore.zzkg$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.util.Function" on path: DexPathList[[zip file "/data/app/com.test.notes.notes-1/base.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.test.notes.notes-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 com.google.android.gms.internal.firebase-firestore.zzfu.zzd(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzeg.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcj.zza(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcl.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.firebase-firestore.zzkg$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.test.notes.notes-1/split_lib_slice_7_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:112)
at dalvik.system.DexFile.<init>(DexFile.java:77)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:359)
at dalvik.system.DexPathList.makeElements(DexPathList.java:323)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:263)
at dalvik.system.DexPathList.<init>(DexPathList.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
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:58)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:541)
2018-11-09 18:33:22.546 24224-24224/com.test.notes.notes E/AndroidRuntime: at android.app.LoadedApk.getClassLoader(LoadedApk.java:574)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1900)
at android.app.LoadedApk.getResources(LoadedApk.java:787)
at android.app.ContextImpl.<init>(ContextImpl.java:2038)
at android.app.ContextImpl.createAppContext(ContextImpl.java:1983)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5439)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1576)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
And I think my build.gradle is needed so here is my build.gradle(Project: test):
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.test.notes.notes"
minSdkVersion 16
targetSdkVersion 27
versionCode 17
versionName "5.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:support-vector-drawable:27.0.2'
implementation 'com.google.firebase:firebase-firestore:15.0.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.1.1'
api 'com.joooonho:selectableroundedimageview:1.0.1'
api 'com.github.bumptech.glide:glide:3.7.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.google.firebase:firebase-core:16.0.5'
api 'com.google.firebase:firebase-firestore:15.0.0'
api 'com.google.firebase:firebase-storage:16.0.4'
api 'com.google.firebase:firebase-auth:16.0.5'
api 'com.crashlytics.sdk.android:crashlytics:2.9.5'
}
apply plugin: 'com.google.gms.google-services'
With that error, the app crashes.
I think there could be anything wrong with the firebase SDK, but can't figure it out?
Please help me to fix this. I didn't find a way to fix it, for a long time.:(
EDIT:
After updated everything to the newest version and added:
multiDexEnabled true
...everything works fine. But now I have the Problem, why I downgraded the versions finally. Please have a look at my question: I don't get a response:
Updating code after firebase 16.0.+ update
When I could fix that everything would be fine.
I see a whole mess of problems in your build.gradle.
The first category of issues is that most of your dependencies are pretty outdated.
The Android API 27 support libraries are on 27.1.1, not 27.0.2.
firebase-firestore is on 17.1.2, not 15.0.0.
firebase-ui-firestore is on 4.2.1, not 2.1.1.
glide is on 4.8.0, not 3.7.0.
Dependency versions should be up-to-date in general, but absolutely must be up-to-date if they're from Google. Otherwise you run into exactly the type of error you have.
The second problem is that you implement firebase-firestore twice, once with implementation and again with api. Remove one or the other.
A handy tip: if a dependency is highlighted in yellow, that means it's outdated! Click the text, hit Alt+Enter and choose the option to update it to the latest version.
Very much aware there are similar questions. Tried all the answers, none of them helped.
Everything works just fine when I upload the apk to my phone with Android Studio but when I download and install the apk I get this nonsense:
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5945)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5534)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5473)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6209)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-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 android.app.ActivityThread.installProvider(ActivityThread.java:5930)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5534)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5473)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6209)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
The app is pretty much only a webview wrapper for a webapp + widget + GCM functionality that receives push messages and shows notifications. If I get this to work, I might never need to touch Android again, so for the love of god please help me with this final issue.
Here's my build.gradle files:
Project:
// 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:2.3.3'
classpath 'com.google.gms:google-services:3.0.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
}
Module:
apply plugin: 'com.android.application'
//apply plugin: "com.ewerk.gradle.plugins.annotation-processor"
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true //tried this due to one answer, didnt do anything
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
/*
configurations.all {
resolutionStrategy {
force 'com.android.support:design:23.4.0'
force 'com.android.support:support-v4:23.4.0'
force 'com.android.support:appcompat-v7:23.4.0'
}
}
*/
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//compile 'com.android.support:appcompat-v7:24.4.0'
//compile 'com.jakewharton:butterknife-compiler:8.4.0'
//annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.jakewharton:butterknife:8.4.0'
//compile 'com.google.android.gms:play-services-gcm:10.0.1'
//compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
//compile 'com.firebase:firebase-client-android:2.3.1'
// https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp
compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5'
}
apply plugin: 'com.google.gms.google-services'
Yessss, finally. Goodbye android!
Turns out the APK android studio had built during normal build processes was crap for some reason. Build-> Build APK built a 3x bigger apk file that worked when downloaded too.