Search code examples
androidgradlefirebasefirebase-crash-reporting

I cannot get firebase crash report working on Android


Here are my build.gradle files.

// 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.2.1'
        classpath 'com.google.gms:google-services:2.1.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Here is another one

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId 'com.example.app'
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    //compile 'com.google.firebase:firebase-core:9.8.0'
    compile 'com.google.firebase:firebase-ads:9.8.0'
    compile 'com.google.firebase:firebase-crash:9.8.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
    compile project(path: ':standOut')
}

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

Gradle Sync goes normally, but when I try to run the app I get the following error

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/measurement/AppMeasurementService.class

If I change the line classpath 'com.google.gms:google-services:2.1.2' to classpath 'com.google.gms:google-services:3.0.0' and sync gradle files I can run the app, when I run it on a real device I get this error.

E/FirebaseCrash: Failed to initialize crash reporting: com.google.android.gms.internal.zztl$zza: No acceptable module found. Local version is 0 and remote version is 0.

When later I do something to crash my app on purpose I don't get any crash report. But when I run the same app on Samsung Galaxy S3 Mini and crash my app I do get a crash report.

On first device play services version is 9.4, on Samsung it's 9.8. Why when I use version 3.0.0 of google services plugin it works on Samsung and does not work on other devices (I tried to run the app on two other devices and it didn't work on either of them)?

Why do I get this duplicate entry error when I use plugin version 2.1.2? Also, I checked versions of plugin on jcenter and version 2.1.2 is dated 3 Jun, 2016 and 3.0.0 is 18 May, 2016 (https://bintray.com/android/android-tools/com.google.gms.google-services). So, which version is the latest and which version should I use?

Do you think I need this line compile 'com.google.firebase:firebase-core:9.8.0'. I tried to do with and without it, it does not seem to make any difference.


Solution

  • It turns out that the google play services version on the devices cannot be lower than the version of the library used. The google services plugin downloaded version 9.8. On Samsung I have version 9.8 and crash reporting works, but on other devices I have version 9.4 and it didn't work. IMHO it's wrong, because that means that I will not get crash report from the users who have google play services version lower than 9.8.

    I tried to find a way to make firebase crash reporting work with plugin version 2.1.2, as I couldn't do that I used version 3.0.0. It seems like version 3.0.0 is the way to go, I just wonder why the latest version is 2.1.2.

    As I switched to version 3.0.0 and updated play services to version 9.8 on the device everything worked.