Error:Execution failed for task ':asynctask:packageDebug'
来源:互联网 发布:c语言运算符号意义大全 编辑:程序博客网 时间:2024/06/01 09:57
出错情形:
在项目里面导入apache官方下载的jar包:
httpclient-4.5.1.jar
httpcore-4.4.3.jar
httpclient-cache-4.5.1.jar
我的build.gradle文件:
<pre name="code" class="plain">apply plugin: 'com.android.application'android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.example.lake.asynctask" minSdkVersion 11 targetSdkVersion 23 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:23.0.1' compile files('libs/httpcore-4.4.3.jar') compile files('libs/httpclient-cache-4.5.1.jar')}
在代码通过编译运行正确的情况下,报出如下错误:
Information:Gradle tasks [:asynctask:assembleDebug]
:asynctask:preBuild UP-TO-DATE
:asynctask:preDebugBuild UP-TO-DATE
:asynctask:checkDebugManifest
:asynctask:preReleaseBuild UP-TO-DATE
:asynctask:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:asynctask:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:asynctask:prepareDebugDependencies
:asynctask:compileDebugAidl UP-TO-DATE
:asynctask:compileDebugRenderscript UP-TO-DATE
:asynctask:generateDebugBuildConfig UP-TO-DATE
:asynctask:generateDebugAssets UP-TO-DATE
:asynctask:mergeDebugAssets UP-TO-DATE
:asynctask:generateDebugResValues UP-TO-DATE
:asynctask:generateDebugResources UP-TO-DATE
:asynctask:mergeDebugResources UP-TO-DATE
:asynctask:processDebugManifest UP-TO-DATE
:asynctask:processDebugResources UP-TO-DATE
:asynctask:generateDebugSources UP-TO-DATE
:asynctask:processDebugJavaRes UP-TO-DATE
:asynctask:compileDebugJavaWithJavac UP-TO-DATE
:asynctask:compileDebugNdk UP-TO-DATE
:asynctask:compileDebugSources UP-TO-DATE
:asynctask:preDexDebug UP-TO-DATE
:asynctask:dexDebug UP-TO-DATE
:asynctask:validateDebugSigning
:asynctask:packageDebug
Error:duplicate files during packaging of APK /home/lake/android_workspace/Thread_Handler_AsyncTask/asynctask/build/outputs/apk/asynctask-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES
Origin 1: /home/lake/android_workspace/Thread_Handler_AsyncTask/asynctask/libs/httpclient-cache-4.5.1.jar
Origin 2: /home/lake/android_workspace/Thread_Handler_AsyncTask/asynctask/libs/httpcore-4.4.3.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
Error:Execution failed for task ':asynctask:packageDebug'.
> Duplicate files copied in APK META-INF/DEPENDENCIES
File 1: /home/lake/android_workspace/Thread_Handler_AsyncTask/asynctask/libs/httpclient-cache-4.5.1.jar
File 2: /home/lake/android_workspace/Thread_Handler_AsyncTask/asynctask/libs/httpcore-4.4.3.jar
Information:BUILD FAILED
Information:Total time: 2.135 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console
解决方法:
在build.gradle中添加内容如下:
apply plugin: 'com.android.application'android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.example.lake.asynctask" minSdkVersion 11 targetSdkVersion 23 versionCode 1 versionName "1.0" } 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' }}dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:23.0.1' compile files('libs/httpcore-4.4.3.jar') compile files('libs/httpclient-cache-4.5.1.jar')}
这个不仅可以解决"Duplicate files" 错误,还可以忽略 apache's libs 和dependency error 。
- Error:Execution failed for task ':asynctask:packageDebug'
- Error:Execution failed for task ':app:packageDebug'.
- Error:Execution failed for task ':app:packageDebug'...
- Android Studio 发生 Error:Execution failed for task ':app:packageDebug'.
- Android Studio Error:Execution failed for task ':app:packageDebug'.
- android studio Error:Execution failed for task ':app:packageDebug'.解决方案
- Error:Execution failed for task ':app:packageDebug'. > !zip.isFile() 解决方案
- Error:Execution failed for task ':app:packageDebug'解决方案
- Error:Execution failed for task ':app:packageDebug'. > Duplicate files copied in APK META-INF/LICENS
- Error:Execution failed for task ':app:packageDebug'. > Duplicate files copied in APK META-INF/LICENS
- Android Studio集成友盟分享运行时报Error:Execution failed for task ':app:packageDebug'.
- 一步解决AndroidStudio问题Error:Gradle: Execution failed for task ':app:packageDebug'.class org.bouncycastl
- AndroidStudio编译错误,Execution failed for task ':app:packageDebug'.
- (记录学习android遇到的问题)Error:Execution failed for task ':app:packageDebug'. > Failed to create
- Error:Execution failed for task ':app:dexDebug'.
- Error:Execution failed for task ':app:compileDebugAidl'.
- Error:Execution failed for task ':app:dexDebug'.
- Error:Execution failed for task ':app:processDebugResources'.
- cocos2d-x跨平台游戏开发视频教程(一)
- 面向 iOS 开发的十款 XCode 插件
- 洛谷P2361 yyy棋
- 正则表达式30分钟入门教程
- 对付拖延心理的方法
- Error:Execution failed for task ':asynctask:packageDebug'
- [黑马训练营]IOS C语言运算符
- centos7+mairadb练习2
- Java 八大排序之——堆排序
- Velocity浅析及与Jsp、Freemarker对比
- Android DrawerLayout demo(抽屉菜单)
- BestCoder Round #60 GT and numbers (模拟)
- Java 八大排序之——快速排序
- JDBC-ecplise连接MySql数据库