2015-10-20 53 views
1

我試圖用Android Studio運行我的Android應用程序,並且顯示錯誤消息,並顯示以下消息。Android:build.gradle中的重複條目

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. 
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: com/mikepenz/iconics/core/BuildConfig.class 

它似乎有一個重複的庫,所以這就是爲什麼它停止運行。但我真的不知道我應該修復build.gradle文件。所以我把我的build.gradle文件放在這裏,有人請幫助我。

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

//wrap with try and catch so the build is working even if the signing stuff is missing 
try { 
    apply from: '../../../signing.gradle' 
} catch (ex) { 
} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.marshall.opensurvey" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 

     applicationVariants.all { variant -> 
      variant.outputs.each { output -> 
       def file = output.outputFile 
       def fileName = file.name.replace(".apk", "-v" + versionName + "-c" + versionCode + ".apk") 
       output.outputFile = new File(file.parentFile, fileName) 
      } 
     } 
    } 
    buildTypes { 
     debug { 
      applicationIdSuffix ".debug" 
      versionNameSuffix "-DEBUG" 
      try { 
       signingConfig signingConfigs.debug 
      } catch (ex) { 
      } 
      minifyEnabled false 
     } 
     release { 
      try { 
       signingConfig signingConfigs.release 
       minifyEnabled false 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      } catch (ex) { 
      } 
      zipAlignEnabled true 
      minifyEnabled false 
     } 
    } 
    lintOptions { 
     abortOnError false 
    } 
} 

repositories() { 
    mavenCentral() 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.1.0' 
    compile 'com.android.support:support-v13:23.1.0' 
    compile 'com.squareup.okhttp:okhttp:2.0.0' 
    compile 'com.android.support:support-v4:23.1.0' 
    compile 'com.android.support:design:23.1.0' 
    compile 'com.squareup.picasso:picasso:2.3.2' 

    // Google Analytics Library 
    compile 'com.google.android.gms:play-services-analytics:8.1.0' 
    compile 'com.google.android.gms:play-services:8.1.0' 

    // Glide Library 
    compile 'com.github.bumptech.glide:glide:3.6.1' 

    // Material Drawer Library by Mike Penz 
    compile('com.mikepenz:materialdrawer:[email protected]') { 
     transitive = true 
    } 

    // Android Iconics Library by Mike Penz 
    compile 'com.mikepenz:iconics-core:[email protected]' 
    compile 'com.mikepenz:google-material-typeface:[email protected]' 

    // Circle image view library 
    compile 'de.hdodenhof:circleimageview:2.0.0' 

    // AboutLibraries by Mike Penz 
    compile('com.mikepenz:aboutlibraries:[email protected]') { 
     transitive = true 
    } 
} 

回答

0

您的依賴關係是相互衝突的。

duplicate entry: com/mikepenz/iconics/core/BuildConfig.class

這意味着你的兩個依賴含有該類

// Android Iconics Library by Mike Penz 
compile 'com.mikepenz:iconics-core:[email protected]' 
compile 'com.mikepenz:google-material-typeface:[email protected]' 

// AboutLibraries by Mike Penz 
compile('com.mikepenz:aboutlibraries:[email protected]') { 
    transitive = true // <- Why? 
} 

我的猜測是要麼transitive不應該被指定或com.mikepenz庫的一個實際上包含其他庫之一。例如,如果iconics-core包含在aboutlibraries,那麼你應該通過

compile('com.mikepenz:aboutlibraries:[email protected]') { 
    exclude module: 'com.mikepenz', name: 'iconics-core' 
} 

一個簡單的方法排除經由gradle dependencies運行gradle這個任務dependencies追查依賴性問題。這顯示了一個很好的庫依賴於其他庫的圖表

+0

在自述文件中陳述了傳遞,並將解析給定庫的所有子依賴關係(在aboutlibraries中爲recyclerview,cardview,appcompat)android-iconics爲no關於圖書館的依賴性。 – mikepenz