火力地堡:无法初始化崩溃报告

问题描述:

我的build.gradle文件火力地堡:无法初始化崩溃报告

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:design:22.2.1' 
    compile 'com.google.firebase:firebase-core:9.4.0' 
    compile "com.google.firebase:firebase-auth:9.4.0" 
    compile 'com.google.firebase:firebase-crash:9.4.0' 

} 

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

我这是如何初始化火力崩溃:

FirebaseCrash.report(new Exception("My first Android non-fatal error")); 

,但我从logcat中得到这个:

Failed to initialize crash reporting 
    com.google.firebase.crash.internal.zzg$zza: com.google.android.gms.internal.zzsb$zza: 
No acceptable module found. Local version is 0 and remote version is 0. 
+0

您是否可以使用您正在测试的设备上安装的Play Services版本更新此版本? –

+0

@DougStevenson我正在模拟器中测试,并且Play服务已更新。 降级到firebase 9.0.2解决了这个问题。 –

+0

您应该始终能够使用最新的客户端库。您可以验证模拟器上运行的Play服务的版本吗?这是重要的一部分。 –

如果您没有在设备上更新Google Play服务或者根本没有安装它,崩溃报告将不会初始化。

+0

Google Play服务已在我的设备上安装并更新,但仍然出现此错误 –

+0

仅当您没有安装或更新Google Play服务时才会引发此错误,因此请在模拟器上使用Google API进行尝试,看看它是否有效 – mayosk

+0

否,它不工作 –

我同意@user6749691的失败很可能是由于Google Play服务的旧版本或不存在造成的。问题是discussed here

您可以确认已安装的播放服务就足够了加入这个方法,把它当你的应用程序初始化支持火力地堡:

private void showGooglePlayServicesStatus() { 
    GoogleApiAvailability apiAvail = GoogleApiAvailability.getInstance(); 
    int errorCode = apiAvail.isGooglePlayServicesAvailable(this); 
    String msg = "Play Services: " + apiAvail.getErrorString(errorCode); 
    Log.d(TAG, msg); 
    Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); 
} 

检查错别字,这可能是一个原因了。

compile 'com.google.firebase:firebase-ads:11.0.2' 
compile 'com.google.firebase:firebase-core:11.0.2' 
compile 'com.google.firebase:firebase-messaging:11.0.2' 
compile 'com.google.firebase:firebase-crash:11.0.1' 

愚蠢的错误,很难找到,但例如,我有x.x.1,而不是x.x.2,并且所有的Firebase/Google Play服务库都应使用相同的版本。