21

Received numbers of crash report from Firebase Crashlytics. It is related to firebase-perf I think.

Fatal Exception: java.lang.NoClassDefFoundError: com.google.android.gms.internal.firebase-perf.zzw
   at com.google.firebase.perf.metrics.Trace.start(Unknown Source:44)
   at com.google.android.gms.internal.firebase-perf.zze.onActivityStarted(Unknown Source:48)
   at android.app.Application.dispatchActivityStarted(Application.java:205)
   at android.app.Activity.onStart(Activity.java:1150)

Already using the newest version of Firebase and Google Play Services.

It does not crash on devices in Firebase Test Lab. But ~1% of user facing this problem.

Is it related to absent of GMS Core? If so, how to handle it properly, not causing crash on those devices?

--- Update ---

project build.gradle

buildscript {
    repositories {
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
        jcenter()

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha04'
        classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

App build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'io.fabric'

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

    defaultConfig {
        applicationId "MASKED"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode "MASKED"
        versionName "MASKED"
        resConfigs "en"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        dataBinding {
            enabled = true
        }
    }


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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
        textReport true
        textOutput 'stdout'
        checkReleaseBuilds false

    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
    implementation 'androidx.annotation:annotation:1.0.0-rc01'
    implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
    implementation 'androidx.leanback:leanback:1.0.0-rc01'
    implementation 'androidx.cardview:cardview:1.0.0-rc01'
    implementation 'androidx.gridlayout:gridlayout:1.0.0-rc01'
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.google.firebase:firebase-config:16.0.0'
    implementation 'com.google.firebase:firebase-perf:16.0.0'

    implementation 'com.google.android.material:material:1.0.0-rc01'
    implementation 'com.google.android.gms:play-services-oss-licenses:16.0.0'
    implementation 'com.google.android:flexbox:1.0.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'

}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Fung
  • 961
  • 1
  • 8
  • 17
  • Please add the content for both of your `build.gradle` files. – Alex Mamo Aug 20 '18 at 15:10
  • What is the API level of the devices on which the exception occurs? I am seeing this problem on API 28. – Bob Snyder Aug 20 '18 at 18:39
  • Different API level facing this problem. From Android 5.1.1 to Android 8. But mostly Android 6. – Fung Aug 21 '18 at 01:38
  • It's happening for me as well. – niqueco Aug 21 '18 at 18:25
  • 2
    Hello! I'm from the Firebase Performance Monitoring team. I have a couple questions to help us figure out where this bug is. 1. Do you see this problem when running on android studio or on production apps via crashlytics? 2. If it's crashlytics, do you use Android App Bundles (https://developer.android.com/platform/technology/app-bundle/) – mike_haney Aug 30 '18 at 20:18
  • @mike_haney 1. I cannot reproduce it in my env. Those error are received from Crashlytics. 2. Both APK and AAB release will have similar crash report. – Fung Aug 31 '18 at 03:48
  • @mike_haney: I was seeing the problem both with release builds (via Crashlytics) and debug builds. I don't use App Bundles. The problem resolved after I upgraded Android Studio to use Android Gradle Plugin `3.3.0-alpha08` and also upgraded to the [Aug 23 release](https://firebase.google.com/support/release-notes/android) of the Firebase SDK. I also disabled R8 with `android.enableR8=false` and used Proguard for minification of release builds. Not sure if all these changes were needed. – Bob Snyder Sep 02 '18 at 14:34
  • @mike_haney We're suffering from the same crashes – Lars Blumberg Sep 03 '18 at 09:25
  • @mike_haney I am getting crashes from both Production and debug, it happens every-time I open the app. It started when I updated com.google.firebase:firebase-perf:16.1.0 I am rolling back to 16.0.0. The stacktrace points at a line that has a logEvent method from FirebaseAnalytics and in debug build says that I have not called FirebaseApp.initializeApp(this) even if I explicitly called from my Application class. – EdgarMarcoPolo Sep 14 '18 at 15:13
  • @mike_haney I have a device in hands and I can reproduce the error on it with all of my apps – Demetrio Guilardi Sep 26 '18 at 14:33
  • Be sure to let @Tejas know in the below answer, he's the engineer resolving these issues – mike_haney Sep 27 '18 at 02:31

2 Answers2

9

Firebase support has just confirmed me this is a bug. They are working on this right now (although they weren't able to reproduce it yet). So we should expect this to be fixed in a future Firebase release.

niqueco
  • 2,261
  • 19
  • 39
  • Did Firebase Support suggest anything to work around the problem? I haven't been able to figure out what library or tool downgrade I need to do to get back to a working configuration. – Bob Snyder Aug 22 '18 at 15:47
  • They didn't say. I'll ask. – niqueco Aug 22 '18 at 15:50
  • 3
    after I've upgraded com.google.firebase:firebase-perf to 16.1.0 my users started experiencing crashes as well, just gonna roll back to 16.0.0 – KgaboL Aug 23 '18 at 16:16
  • 1
    @niqueco Can we get a link to the bug report? – Minas Mina Aug 26 '18 at 14:54
  • 2
    @MinasMina There's no bug report. I had a conversation with Firebase support. They confirmed the issue but they could not reproduce it. Yesterday I got the last email saying that as they still can't reproduce it locally they will close my report and "monitor" the situation. (?) – niqueco Aug 26 '18 at 15:14
  • 2
    I am facing the very same thing. The version is 16.1.0. To reproduce, launch the app and wait 30 minutes. The app will never be launched again. – Demetrio Guilardi Sep 26 '18 at 14:26
6

Update: Please update to Firebase Performance Version 16.2.5 to solve this issue.

Tejas
  • 123
  • 7
  • Build a new version without Multidex. Let see if it help. BTW, Multidex w/ AndroidX is having a much slower cold starts...... – Fung Sep 05 '18 at 05:57
  • @niqueco Did you face problem 1 or problem 2? – Tejas Sep 06 '18 at 16:18
  • 1
    Update: Issue seems gone after removing multidex. – Fung Sep 11 '18 at 02:55
  • @Tejas Problem 1. I got lots of crashes in Crashlytics in my app (no multidex) untill I downgraded firebase-perf. – niqueco Sep 14 '18 at 14:12
  • @niqueco Can you share device/OS combos that this crash happens on? – Tejas Sep 19 '18 at 23:01
  • @Tejas Yes... -- Moto G (2nd gen) - Android 6.0 ; Galaxy Note 4 - Android 6.0.1 ; Galaxy S5 mini - Android 6.0.1 ; Galaxy S5 Neo - Android 6.0.1 -- I thought there were non Android 6 errors, but I can't find them now. – niqueco Sep 23 '18 at 21:16
  • We're seeing lots of the `NoClassDefFoundError` in Crashlytics and Play crash reports, so far across Android 5 and 6 versions. @Tejas, we tried a proguard change (https://github.com/opendatakit/collect/pull/2548/files) and that didn't help. The project is open source if that can help (https://github.com/opendatakit/collect/issues/2542). Can't reproduce locally so disabling the lib for now. – Hélène Martin Sep 24 '18 at 23:24
  • Device manufacturers: 33% samsung, 23% Xiaomi, 20% LENOVO, 17% ZTE 7% Other. Also seeing a Huawei in a different report of the same crash (seems it can happen from different activities) so I don't think it's related to device. – Hélène Martin Sep 24 '18 at 23:53
  • 1
    I can reproduce the error!!! I have a device in my hands right now and I can reproduce it wherever I want – Demetrio Guilardi Sep 26 '18 at 14:28
  • @Tejas Has this been fixed? There's a 16.1.2 release, but no release notes has been posted. Should I upgrade? Thanks. – niqueco Oct 05 '18 at 16:22
  • @niqueco. No it is not fixed. I can reproduce the error on version 16.1.2 as well – Demetrio Guilardi Oct 08 '18 at 04:24
  • 1
    @everyone - Please try using version 16.2.0 of the firebase performance SDK - we've added a potential fix to it. Thanks! – Tejas Oct 25 '18 at 18:58
  • 1
    @Tejas This still occurs on 16.2.0. Using com.google.firebase:firebase-plugins:1.1.5 – Luke Brandon Farrell Nov 05 '18 at 12:19
  • 1
    @LukeBrandonFarrell Would you be able to share the stacktrace of the issue? (Ideally uploaded to a github gist or a pastebin) – Tejas Nov 05 '18 at 20:15
  • @Tejas any update on this bug? Looks like we're now on 16.2.3 of firebase-perf. Have there been any fixes? – user1809913 Feb 11 '19 at 21:22
  • 1
    We've identified the problem and are working on a fix - I'll update the answer once we're able to ship it! – Tejas Feb 12 '19 at 00:05
  • @user1809913 Please update to version 16.2.4 of firebase performance to fix this issue. – Tejas Mar 11 '19 at 23:46