2017-09-06 87 views
2

错误Bulid APK 此代码中存在什么问题?火力地堡?我尝试清洁和重建。但是我有这个错误。错误构建APK错误:执行任务失败':app:transformClassesWithDexForRelease'

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/inject/Inject.class

我的应用程序文件的gradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.1" 
    defaultConfig { 
     applicationId "myapp.over.app" 
     minSdkVersion 15 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     vectorDrawables.useSupportLibrary = true 

     multiDexEnabled true 
     } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/dependencies.txt' 
     exclude 'META-INF/LGPL2.1' 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support:design:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.google.firebase:firebase-auth:10.0.1' 
    compile 'com.google.firebase:firebase-database:10.0.1' 
    compile 'me.anwarshahriar:calligrapher:1.0' 
    compile 'com.github.mvpotter:kladr-api-client:0.6.1' 
    compile 'com.google.firebase:firebase-storage:10.0.1' 

    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:multidex:1.0.1' 

} 









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

allprojects { 
    repositories { 
     maven { url 'https://jitpack.io' } 
    } 
} 

什么,我需要做什么?

+0

您是否尝试过使缓存无效并重新启动,然后进行清理和重建? –

+0

我试试。它没有帮助 –

回答

0

这发生在我身上一次,这个问题特别是

duplicate entry: javax/inject/Inject.class

所以我检查了我的依赖关系,并发现我得到了依赖多个申报,所以去到你的库文件夹,并检查是否有那也是在你的依赖声明

compile fileTree(include: ['*.jar'], dir: 'libs') 

最有可能其中的一个jar文件已经在您的libs文件夹:

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support:design:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.google.firebase:firebase-auth:10.0.1' 
    compile 'com.google.firebase:firebase-database:10.0.1' 
    compile 'me.anwarshahriar:calligrapher:1.0' 
    compile 'com.github.mvpotter:kladr-api-client:0.6.1' 
    compile 'com.google.firebase:firebase-storage:10.0.1' 

    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:multidex:1.0.1' 
+0

我不包含目录库。 –

+0

你的'libs'的内容是什么? – Orvenito

+0

我可以在文件夹.idea javax_inject_1.xml和javax_inject_2_5_0_b32.xml中创建2个库。也许这是错误?但我不知道什么库生成这 –

0

问题在Maven中。 Maven不能包含在Gradle中。

相关问题