2017-09-26 92 views
0

我正在使用Firebase和API.AI製作Android聊天漫遊器應用程序。 在項目中添加firebase UI lib後,我得到了java.util.zip.ZipException:重複條目運行時異常。之後,我添加了javaMaxHeapSize =「4g」,但找不到解決方案。 FirebaseUI版本,但沒有一個能夠工作。ZipException:重複條目異常

還有其他類似的問題,但每個類都有不同的build.grade。

這裏是信息:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. 
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class 

搖籃文件:

第二個
apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
    applicationId "com.bot.chatbot.chatbot" 
    minSdkVersion 16 
    targetSdkVersion 25 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    multiDexEnabled = true 
    } 
    dexOptions { 
    javaMaxHeapSize = "4g" 
    } 
    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' 
    }) 

    //Google 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support:recyclerview-v7:25.3.1' 
    compile 'com.android.support:design:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 

    //AI 
    compile 'ai.api:sdk:[email protected]' 
    compile 'ai.api:libai:1.4.8' 
    compile 'com.google.code.gson:gson:2.3.1' 
    compile 'commons-io:commons-io:2.4' 

    //Firebase 
    compile 'com.google.firebase:firebase-core:10.2.1' 
    compile 'com.google.firebase:firebase-storage:10.2.1' 
    compile 'com.google.firebase:firebase-auth:10.2.1' 
    compile 'com.google.firebase:firebase-database:10.2.1' 
    compile 'com.firebaseui:firebase-ui:0.4.3' 
    compile 'com.firebaseui:firebase-ui-database:2.3.0' 


    testCompile 'junit:junit:4.12' 
} 


apply plugin: 'com.google.gms.google-services' 

buildscript { 
     repositories { 
     jcenter() 
     } 
     dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
     classpath 'com.google.gms:google-services:3.1.0' 

     } 
    } 

    allprojects { 
     repositories { 
     jcenter() 
     } 
    } 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 
+0

ZIP文件只能包含文件位置一次。部分任務將兩次添加條目。 – Konrad

+0

[FirebaseUI文檔](https://github.com/firebase/FirebaseUI-Android#dependencies)解釋了版本兼容性的要求。對於Firebase庫10.2.1,使用'firebase-ui:1.2.0'。並刪除'firebase-ui-database'的行。因爲您使用'firebase-ui:1.2.0'包含了所有的FirebaseUI,所以不需要。 –

回答

0

發生這種情況,因爲你混合舊的依賴性用新的。因此,爲了解決您的問題,請從build.gradle文件中刪除以下代碼行。

compile 'com.firebaseui:firebase-ui-database:2.3.0' 

這行代碼是不需要的,這就是爲什麼你得到duplicate entry exception。請參閱FirebaseUI的版本兼容性,我建議您查看官方documentation