gpt4 book ai didi

java - 错误 :duplicate files during packaging of APK Android Studio Error

转载 作者:太空宇宙 更新时间:2023-11-03 12:51:25 24 4
gpt4 key购买 nike

我在运行应用程序时在 Android studio 中遇到意外错误,以下是收到的错误消息

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

我也在粘贴我的 build.gradle 文件

 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'
}
// ...
}

最佳答案

好吧,您错过了构建 gradle 的流程。当您尝试使用 2 个 android {..} fragment 时,它没有检测到第二个 fragment 。因此,您对重复元文件的排除不起作用。

可能的解决方案:

只需更改构建 gradle 的顺序,如下所示:

    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"


}

如果仍然无效,请检查以下内容:

它是你的库构建 gradle 吗?我从我的主要项目构建 gradle 中排除了重复的元文件。因此,请确保从应用程序模块而不是库模块的构建 gradle 中排除元文件。

关于java - 错误 :duplicate files during packaging of APK Android Studio Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30364950/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com