我正在使用firebase构建一个应用程序但是得到了Duplicate类错误.我检查了所有依赖项,但我无法弄清楚我在哪里有两个版本的firebase库.错误:
任务’:app:transformClassesWithJarMergingForDebug’的执行失败.
任务’:app:transformClassesWithJarMergingForDebug’的执行失败.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/iid/zzb$1.class
buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'io.fabric.tools:gradle:1.+' } } apply plugin: 'com.android.application' apply plugin: 'io.fabric' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 25 buildToolsVersion '24.0.3' defaultConfig { applicationId "com.android.palmtickle" minSdkVersion 14 targetSdkVersion 25 versionCode 1 versionName "1.0" //Enabling multiDex support. multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro' } } } repositories { mavenCentral() maven { url 'http://dl.bintray.com/amulyakhare/maven' } maven { url 'https://maven.fabric.io/public' } } dependencies { compile('com.digits.sdk.android:digits:2.0.6@aar') { transitive = true; } //support and app compatibility libs compile 'com.android.support:appcompat-v7:25.3.0' compile 'com.android.support:design:25.3.0' compile 'com.android.support:cardview-v7:25.3.0' compile 'com.android.support:recyclerview-v7:25.3.0' compile 'com.android.support:support-v4:25.3.0' compile 'com.google.code.gson:gson:2.7' compile 'com.squareup.retrofit:retrofit:1.9.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'de.hdodenhof:circleimageview:2.0.0' compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' compile 'com.wdullaer:materialdatetimepicker:2.1.1' //entries related to firebase compile 'com.google.firebase:firebase-auth:10.2.1' compile 'com.google.firebase:firebase-database:10.2.1' compile 'com.google.guava:guava-base:r03' compile 'com.yalantis:ucrop:2.2.0-native' }
因为我总是试图通过在Android Studio中搜索重复文件来解决这样的错误.当我在android studio中搜索类zzb时,我得到了一个jar firebase-iid-9.0.0以及所有其他10.2.1 firebase类.我无法找出注入此firebase-iid-9.0.0 jar的依赖项?任何的想法?
解决方法
尝试将buildToolsVersion更新为25.0.2
我今天面临同样的问题,我尝试使用
compile 'com.google.firebase:firebase-core:10.2.1' compile 'com.google.firebase:firebase-messaging:10.2.1'
清理项目和重建项目
一切都很好
检查支持库是每个模块的版本25.3.0,并确保所有firebase模块都是10.2.1