美好的一天,我正在进行FireBase云通知,我将会收到
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / android / gms / common / api / zza.class
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "aminfocraft.harsh.firebasenotificationdemo"
minSdkVersion 15
multiDexEnabled true
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
apply plugin: 'com.google.gms.google-services'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
./ gradlew clean也无法正常工作
答案 0 :(得分:2)
问题1
致电 apply plugin properly
问题2
添加 play-services:10.2.1
试试这种方式
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "aminfocraft.harsh.firebasenotificationdemo"
minSdkVersion 15
multiDexEnabled true
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
答案 1 :(得分:1)
这样:
apply plugin: 'com.google.gms.google-services'
应该在dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
此外,您忘记添加播放服务依赖项..
添加compile 'com.google.android.gms:play-services:10.2.1'
答案 2 :(得分:1)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
应该在依赖项之外
Crashlytics.start(withAPIKey: FABRIC_API_KEY)
答案 3 :(得分:0)
apply plugin: 'com.google.gms.google-services'
应该在依赖项之外
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
此外,您忘记添加播放服务依赖项.. 添加
compile 'com.google.android.gms:play-services:10.2.1
'