【发布时间】:2016-10-29 22:14:34
【问题描述】:
这是我的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.
稍后当我故意使我的应用程序崩溃时,我没有收到任何崩溃报告。但是当我在三星 Galaxy S3 Mini 上运行相同的应用程序并崩溃我的应用程序时,我确实收到了崩溃报告。
在第一台设备上播放服务版本是 9.4,在三星上是 9.8。 为什么当我使用 3.0.0 版的 google services 插件时,它在三星上运行而在其他设备上不运行(我试图在另外两台设备上运行该应用程序,但在其中任何一台上都不起作用)?
为什么我在使用插件版本 2.1.2 时会收到此 duplicate entry 错误?
另外,我检查了 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'。我试着用它和不用它,它似乎没有任何区别。
【问题讨论】:
-
您也可以查看this video。
标签: android gradle firebase firebase-crash-reporting