Ad

Integrating Firebase Causing The Crash In Android

- 1 answer

After I integrated the firebase by following the docs ... I am getting a crash in one of the lines in application class

GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);

Log:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
        at com.google.android.gms.internal.zzark.zzbl(Unknown Source:0)
        at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source:0)
        at com.bmw.bmwsales.BMWSalesApplication.onCreate(BMWSalesApplication.java:83)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1122)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6517)
        at android.app.ActivityThread.-wrap2(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1963)
        at android.os.Handler.dispatchMessage(Handler.java:108)
        at android.os.Looper.loop(Looper.java:166)
        at android.app.ActivityThread.main(ActivityThread.java:7425)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.bmw.bmwsales-uVdnAKZw9szHT_S3LTCH0A==/base.apk"],nativeLibraryDirectories=[/data/app/com.bmw.bmwsales-uVdnAKZw9szHT_S3LTCH0A==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.android.gms.internal.zzark.zzbl(Unknown Source:0) 
        at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source:0) 
        at com.bmw.bmwsales.BMWSalesApplication.onCreate(BMWSalesApplication.java:83) 
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1122) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6517) 
        at android.app.ActivityThread.-wrap2(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1963) 
        at android.os.Handler.dispatchMessage(Handler.java:108) 
        at android.os.Looper.loop(Looper.java:166) 
        at android.app.ActivityThread.main(ActivityThread.java:7425) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 

Code:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "package-name"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 16
        versionName "2.1"

        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    lintOptions {
        checkReleaseBuilds false
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

repositories {
    mavenCentral()
    maven {
        url 'http://maven.batch.com/release'
    }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}

dependencies {
    implementation project(':library')
    implementation project(':urlImageViewHelper')
    //implementation 'com.google.android.gms:play-services:9.6.1'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    //implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:mediarouter-v7:28.0.0'
    implementation 'com.google.code.gson:gson:2.2.4'
    //implementation 'com.batch.android:batch-sdk:1.6.0'
    implementation files('libs/bolts-android-1.2.0.jar')
    implementation files('libs/glide-3.4.0.jar')
    implementation files('libs/imagecoverflow-master.jar')
    implementation files('libs/mint-4.0.7.jar')
    implementation files('libs/Parse-1.9.2.jar')
    implementation files('libs/universal-image-loader-1.9.3-with-sources.jar')
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.github.d-max:spots-dialog:[email protected]'
    implementation 'com.batch.android:batch-sdk:1.13+'
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation 'com.android.support:multidex:1.0.0'

    /*implementation 'com.google.android.gms:play-services-auth:10.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-storage:16.0.1'*/


}
apply plugin: 'com.google.gms.google-services'
Ad

Answer

I solved By:

dependencies {
    implementation project(':library')
    implementation project(':urlImageViewHelper')
    //implementation 'com.google.android.gms:play-services:9.6.1'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    //implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:mediarouter-v7:28.0.0'
    implementation 'com.google.code.gson:gson:2.2.4'
    //implementation 'com.batch.android:batch-sdk:1.6.0'
    implementation files('libs/bolts-android-1.2.0.jar')
    implementation files('libs/glide-3.4.0.jar')
    implementation files('libs/imagecoverflow-master.jar')
    implementation files('libs/mint-4.0.7.jar')
    implementation files('libs/Parse-1.9.2.jar')
    implementation files('libs/universal-image-loader-1.9.3-with-sources.jar')
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.github.d-max:spots-dialog:[email protected]'
    implementation 'com.batch.android:batch-sdk:1.13+'
    implementation "com.google.firebase:firebase-core:12.0.1"

}

It was version conflicts

Ad
source: stackoverflow.com
Ad