Fun*_*LAM 21 android firebase google-play-services firebase-performance
从Firebase Crashlytics收到了大量的崩溃报告.我觉得它与firebase-perf有关.
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)
Run Code Online (Sandbox Code Playgroud)
已经使用最新版本的Firebase和Google Play服务.
它不会在Firebase测试实验室中的设备上崩溃.但约有1%的用户面临这个问题.
是否与缺少GMS Core有关?如果是这样,如何正确处理它,不会导致这些设备崩溃?
---更新---
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
}Run Code Online (Sandbox Code Playgroud)
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'Run Code Online (Sandbox Code Playgroud)
Firebase支持刚刚证实了我这是一个错误.他们现在正在研究这个问题(尽管他们还没有能够重现它).因此,我们应该期望在未来的Firebase版本中修复此问题.
免责声明:这些并不是解决问题的全面解决方案,但现在这应该可以解除阻止.在我们弄清楚的时候,我会跟进一个全面的解决方案.
跟进@ mike_haney的评论(我也在Firebase Performance团队中) - 所有迹象表明,这似乎是与multidex相关的多个不同问题(每个问题可能有不同的解决方案)都会导致ClassDefNotFound错误.
问题1 - 致命异常:生成版本中的java.lang.NoClassDefFoundError:com.google.android.gms.internal.firebase-perf.zzw(firebase-perf:16.1.0)
解决方案 - 这是不可能重现的,但理论上说com.google.android.gms.internal.firebase-perf.zzw(名称仅对firebase-perf 16.1.0有效)类需要出现在主dex中文件取决于运行该应用程序的操作系统的版本.这似乎只会在没有操作系统级别MultiDex支持的特定设备/操作系统变体上崩溃.如果您在野外看到此崩溃,请按照android文档中列出的步骤将类添加到主dex.(我会在结束时跟进更好的文档,但希望现在能解锁你!)
问题2 - 使用Instant Run时出现ClassDefNotFound异常
解决方案 - 这是在使用即时运行时如何完成multidexing/predexing的问题,似乎该过程正在剥离Firebase工作所需的一些类.如果您启用了multidex(并且在许多情况下Instant Run会自动执行),请缩小AND proguard(如下所示)或完全禁用minify.
__PRE__
| 归档时间: |
|
| 查看次数: |
2097 次 |
| 最近记录: |