我正在尝试使用Firebase到我的Android应用程序,并按照https://www.firebase.com/docs/android/quickstart.html的说明 添加到我的build.gradle:
dependencies { compile 'com.firebase:firebase-client-android:2.5.0+' }
并且
android { ... packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' } }
但是当我运行这个项目时.每次我运行项目时它会产生不同的错误,错误是这样的:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/firebase/client/android/AndroidPlatform$2.class
还有这个
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/firebase/tubesock/Base64.class
这是我的build.gradle文件:
apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "..." minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.firebase:firebase-client-android:2.5.0' }
这是我的项目的build.gradle:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.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
在该libs
文件夹中的firebase jar文件中也有firebase管理的依赖项.请删除其中一个,以便项目可以正确编译.