错误:APK的Andr​​oid Studio错误的包装过程中重复的文件 [英] Error:duplicate files during packaging of APK Android Studio Error

查看:234
本文介绍了错误:APK的Andr​​oid Studio错误的包装过程中重复的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到在Android的工作室意外的错误,同时运行的应用程序,以下是我得到的错误讯息


  

错误:APK的包装过程中重复的文件
  /home/jithu/libs/android/android/aa/app/build/outputs/apk/app-debug-unaligned.apk
    路径档案:META-INF /相关内容产地1:
  /home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.6/cf8bacbf0d476c7f2221f861269365b66447f7ec/httpmime-4.3.6.jar
    原产地2:
  /home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636/httpcore-4.4.1.jar


我贴我的build.gradle文件还

 应用插件:'com.android.library安卓{
    compileSdkVersion 21
    buildToolsVersion21.1.2    defaultConfig {
        14的minSdkVersion
        targetSdkVersion 21
        版本code 1
        的versionName1.0
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
}依赖{
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.android.support:appcompat-v7:+
    编译com.google.android.gms:游戏服务:87年6月5日
    编译com.squareup.picasso:毕加索:2.5.2
    编译com.mcxiaoke.volley:库:1.0.15
    编译com.google code.gson:GSON:2.2.4
    编译org.apache.httpcomponents:的HttpCore:4.4.1
    编译org.apache.httpcomponents:httpmime:4.3.6
}
安卓{
    packagingOptions {
        排除META-INF /相关内容
        排除META-INF /注意事项
        排除META-INF / LICENSE
        排除META-INF / LICENSE.TXT
        排除META-INF / NOTICE.txt
    }
    // ...
}


解决方案

那么你缺少的gradle构建的流动。
当你要使用2 安卓{..} 片段它没有检测第二之一。因此,您的重复元文件排除不工作。

可能的解决方法:

只要改变你的Gradle构建的顺序如下图所示:

 应用插件:'com.android.library
    安卓{
        compileSdkVersion 21
        buildToolsVersion21.1.2        defaultConfig {
            14的minSdkVersion
            targetSdkVersion 21
            版本code 1
            的versionName1.0
        }
        buildTypes {
            发布 {
                minifyEnabled假
                proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
            }
        }
        packagingOptions {
            排除META-INF /相关内容
            排除META-INF /注意事项
            排除META-INF / LICENSE
            排除META-INF / LICENSE.TXT
            排除META-INF / NOTICE.txt
        }
    }
依赖{
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.android.support:appcompat-v7:+
    编译com.google.android.gms:游戏服务:87年6月5日
    编译com.squareup.picasso:毕加索:2.5.2
    编译com.mcxiaoke.volley:库:1.0.15
    编译com.google code.gson:GSON:2.2.4
    编译org.apache.httpcomponents:的HttpCore:4.4.1
    编译org.apache.httpcomponents:httpmime:4.3.6
}

如果它仍然没有工作,然后检查以下内容:

这是你的库构建gradle这个?
我排除了我的重复元文件从我的主要项目的gradle构建。因此,请务必从应用模块的gradle构建排除元文件,而不是库模块。

Am getting an unexpected error in Android studio while running the app,following is the error message which am getting

Error:duplicate files during packaging of APK /home/jithu/libs/android/android/aa/app/build/outputs/apk/app-debug-unaligned.apk Path in archive: META-INF/DEPENDENCIES Origin 1: /home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.6/cf8bacbf0d476c7f2221f861269365b66447f7ec/httpmime-4.3.6.jar Origin 2: /home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636/httpcore-4.4.1.jar

Am pasting my build.gradle file also

 apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile 'com.google.code.gson:gson:2.2.4'
    compile "org.apache.httpcomponents:httpcore:4.4.1"
    compile "org.apache.httpcomponents:httpmime:4.3.6"


}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    // ...
}

解决方案

Well you are missing the flow of build gradle. As you are trying to use 2 android {..} snippet it is not detecting the 2nd one. As a result your exclusion of duplicate meta files are not working.

Possible solution:

Just change the order of your build gradle like below:

    apply plugin: 'com.android.library'    
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"

        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
    }
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile 'com.google.code.gson:gson:2.2.4'
    compile "org.apache.httpcomponents:httpcore:4.4.1"
    compile "org.apache.httpcomponents:httpmime:4.3.6"


}

If it still didn't work then check out the following:

Is it your library build gradle? I excluded my duplicate meta files from my main projects build gradle. So make sure to exclude the meta files from build gradle of app module rather than library module.

这篇关于错误:APK的Andr​​oid Studio错误的包装过程中重复的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆