运行Android应用程序时,我收到jar文件的错误

时间:2017-03-06 07:59:03

标签: java android jar

我在使用Eclipse。现在,我在Android Studio中尝试使用相同的应用程序。但是,我收到以下错误:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
    File1: C:\Android\as_workspace\MobilOkul\app\libs\httpclient-4.3.6.jar
    File2: C:\Android\as_workspace\MobilOkul\app\libs\httpcore-4.3.3.jar
    File3: C:\Android\as_workspace\MobilOkul\app\libs\httpmime-4.3.6.jar

Build.Gradle:模块的内容如下:

defaultConfig {
    applicationId "com.mobilokul"
    minSdkVersion 17
    targetSdkVersion 22
}

packagingOptions {
    exclude 'META-INF/NOTICE' // will not include NOTICE file
    exclude 'META-INF/LICENSE' // will not include LICENSE file
    exclude 'META-INF/notice'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license'
    exclude 'META-INF/license.txt'
}

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

删除值packagingOptions时,错误如下。

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
    File1: C:\Android\as_workspace\MobilOkul\app\libs\httpclient-4.3.6.jar
    File2: C:\Android\as_workspace\MobilOkul\app\libs\httpcore-4.3.3.jar
    File3: C:\Android\as_workspace\MobilOkul\app\libs\httpmime-4.3.6.jar

1 个答案:

答案 0 :(得分:1)

使用

更新您的gradle
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}