我正在使用 Firebase 创建 Facebook登录系统。但是当我编译项目时,它给了我:
错误:任务执行失败 ':应用程序:transformClassesWithJarMergingForDebug'。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目: COM /谷歌/机器人/克/普通/ API / zze.class
build.gradle(项目):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.zihadrizkyef.belajar_facebooklogin"
minSdkVersion 19
targetSdkVersion 25
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:5)
所有Firebase库必须是同一版本。使用firebase-auth
版本10.0.0:
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.google.firebase:firebase-auth:10.0.0'
答案 1 :(得分:0)
在我的项目中,在不同的jar或libs中有一些重复的文件,我在我的app build.gradle中添加了一些代码,如下所示:
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INFTICE.txt'
exclude 'META-INFTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INFtice.txt'
exclude 'META-INFcense.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/maven/com.google.protobuf/protobuf-java/pom.xml'
exclude 'META-INF/maven/com.google.protobuf/protobuf-java/pom.properties'
}
它有效。
我想你可能会包含一些其他包含“com / google / android / gms / common / api / zze.class”或整个jar的罐子。
UMeng jars包含protobuf,我的模型也包含,所以我在buildOptions中的build.gradle中排除了两个protobuf-java文件。
答案 2 :(得分:0)
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.google.firebase:firebase-core:10.0.0'
compile ('com.google.firebase:firebase-auth:9.8.0') {
exclude group: 'com.google.android.gms'
}
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'