这是我的 build.gradle
文件。
// 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
}
还有一个
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 正常运行,但是当我尝试运行该应用程序时出现以下错误
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
如果我将行 classpath 'com.google.gms:google-services:2.1.2'
更改为 classpath 'com.google.gms:google-services:3.0.0 '
和同步 gradle 文件我可以运行该应用程序,当我在真实设备上运行它时出现此错误。
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.
当我后来故意做一些事情让我的应用程序崩溃时,我没有收到任何崩溃报告。但是,当我在 Samsung Galaxy S3 Mini 上运行相同的应用程序并使我的应用程序崩溃时,我确实收到了崩溃报告。
第一台设备播放服务版本是 9.4,三星是 9.8。 为什么当我使用 3.0.0 版的谷歌服务插件时,它可以在三星上运行,但不能在其他设备上运行(我尝试在另外两台设备上运行该应用程序,但它在其中任何一台上都不起作用)?
当我使用插件版本 2.1.2 时,为什么会出现此重复输入
错误?
另外,我检查了 jcenter 上的插件版本,版本 2.1.2 的日期是 2016 年 6 月 3 日,而 3.0.0 的日期是 2016 年 5 月 18 日(https://bintray.com/android/android-tools/com.google.gms.google-services)。那么,哪个版本是最新的,我应该使用哪个版本?
你认为我需要这一行 compile 'com.google.firebase:firebase-core:9.8.0'
。我尝试过使用和不使用它,它似乎没有任何区别。
最佳答案
事实证明,设备上的 google play services
版本不能低于所用库的版本。谷歌服务插件下载版本 9.8。在三星上我有 9.8 版并且崩溃报告有效,但在其他设备上我有 9.4 版但它没有工作。恕我直言,这是错误的,因为这意味着我不会收到 google play services
版本低于 9.8 的用户的崩溃报告。
我试图找到一种方法使 firebase 崩溃报告与插件版本 2.1.2 一起工作,因为我无法做到这一点,我使用的是版本 3.0.0。看来3.0.0版本是要走的路,我只是想知道为什么最新版本是2.1.2。
当我切换到 3.0.0 版并将播放服务更新到设备上的 9.8 版时,一切正常。
关于android - 我无法在 Android 上运行 firebase 崩溃报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40324224/