gpt4 book ai didi

android - 任务 ':app:dexDebug' 执行失败。不确定可能是 httpclient 和 httpmime 之间的依赖性问题

转载 作者:太空狗 更新时间:2023-10-29 16:36:27 24 4
gpt4 key购买 nike

在 Android Studio 中,我收到以下错误:-任务 ':app:dexDebug' 执行失败。

:app:compileDebugJava UP-TO-DATE :app:preDexDebug :app:dexDebug UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:dexDebug'.

    com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\Priyatosh\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Priyatosh\Desktop\Camerafileupload27\app\build\intermediates\dex\debug --input-list=C:\Users\Priyatosh\Desktop\Camerafileupload27\app\build\intermediates\tmp\dex\debug\inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。

构建失败

我的 build.gradle 文件:-

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

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



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
//compile files('libs/httpclient-4.3.6.jar')
//compile files('libs/android-support-v4.jar')
//compile files('libs/httpcore-4.3.3.jar')
//compile files('libs/httpmime-4.3.6.jar')
//compile "org.apache.httpcomponents:httpmime:4.3.6"

}

Image

任何人都可以建议我如何解决它......?

最佳答案

你的build.gradle包含compile 'com.android.support:appcompat-v7:21.0.3'这个库依赖在 v4 支持库上。所以它会被gradle添加。你也有 android-support-v4.jar 在你的 libs 文件夹和行 compile fileTree(dir: 'libs', include: ['*.jar' ]),因为 AS 将尝试使用同一库的 2 个实例来构建它。

解决方案是从 libs 文件夹中删除 android-support-v4.jar 并重建项目。

更新:

添加到build.gradle下一个 block

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

关于android - 任务 ':app:dexDebug' 执行失败。不确定可能是 httpclient 和 httpmime 之间的依赖性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27668156/

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