Java Android Studio:错误代码 1:Gradle:任务 ':app:processDebugResources' 执行失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27402048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio: Error Code 1: Gradle: Execution failed for task ':app:processDebugResources'
提问by roger
I want to compile a project, I got Error:Gradle: Execution failed for task ':app:processDebugResources'.
我想编译一个项目,我得到了 Error:Gradle: Execution failed for task ':app:processDebugResources'.
here is the exception:
这是例外:
Error:Gradle: Execution failed for task ':app:processDebugResources'. com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\devtools\adt\sdk\build-tools\21.1.1\aapt.exe package -f --no-crunch -I D:\devtools\adt\sdk\platforms\android-21\android.jar -M E:\code\android\TVMediaPlayer\app\build\manifests\debug\AndroidManifest.xml -S E:\code\android\TVMediaPlayer\app\build\res\all\debug -A E:\code\android\TVMediaPlayer\app\build\assets\debug -m -J E:\code\android\TVMediaPlayer\app\build\source\r\debug -F E:\code\android\TVMediaPlayer\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.skyworth.tvmediaplayer.app --output-text-symbols E:\code\android\TVMediaPlayer\app\build\symbols\debug
Error Code: 1
Output: E:\code\android\TVMediaPlayer\app\build\res\all\debug\drawable-hdpi-v4\ic_launcher.png: error: Duplicate file. E:\code\android\TVMediaPlayer\app\build\res\all\debug\drawable-hdpi\ic_launcher.png: Original is here. The version qualifier may be implied.
错误:Gradle:任务 ':app:processDebugResources' 执行失败。com.android.ide.common.internal.LoggedErrorException:无法运行命令:
D:\devtools\adt\sdk\build-tools\21.1.1\aapt.exe package -f --no-crunch -ID:\devtools\adt\sdk\platforms\android-21\android.jar -ME: \code\android\TVMediaPlayer\app\build\manifests\debug\AndroidManifest.xml -SE:\code\android\TVMediaPlayer\app\build\res\all\debug -AE:\code\android\TVMediaPlayer\app\build \assets\debug -m -JE:\code\android\TVMediaPlayer\app\build\source\r\debug -FE:\code\android\TVMediaPlayer\app\build\libs\app-debug.ap_ --debug- mode --custom-package com.skyworth.tvmediaplayer.app --output-text-symbols E:\code\android\TVMediaPlayer\app\build\symbols\debug
错误代码:1
输出:E:\code\android\TVMediaPlayer\app\build\res\all\debug\drawable-hdpi-v4\ic_launcher.png:错误:重复文件。E:\code\android\TVMediaPlayer\app\build\res\all\debug\drawable-hdpi\ic_launcher.png:原件在这里。版本限定符可能是隐含的。
here is the gradle file:
这是gradle文件:
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "com.jerrellmardis.amphitheatre"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
renderscriptTargetApi 19
buildConfigField "String", "TMDB_API_KEY", "\"${loadSecret("TMDB_API_KEY")}\""
}
......
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:leanback-v17:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:palette-v7:21.0.0'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup.retrofit:retrofit:1.7.1'
compile 'com.google.code.gson:gson:2.3'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.apache.commons:commons-collections4:4.0'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.github.satyan:sugar:1.3'
}
I am puzzled about the error message, am I put the wrong png file or my gradle config file is wrong?
我对错误消息感到困惑,是我放错了 png 文件还是我的 gradle 配置文件错误?
回答by LuckyMalaka
- In case you administrate your own aar files:
- 如果您管理自己的 aar 文件:
You have to ensure that your gradle and buildToolsVersion are identically in your project and the used aars.
您必须确保您的项目和使用的 aars 中的 gradle 和 buildToolsVersion 相同。
- In case you use external libs where you can't control the gradle/build version:
- 如果您使用无法控制 gradle/build 版本的外部库:
Contact the author or check the sources by your own. Some libraries have unused launcher icons which will cause this conflict. Removing this icons will solve your problem. Identically named sources (e.g menu.xml) could also cause this issue in rare cases. An easy workaround would be to rename your ressource.
联系作者或自行查看来源。某些库具有未使用的启动器图标,这将导致此冲突。删除此图标将解决您的问题。在极少数情况下,相同命名的源(例如 menu.xml)也可能导致此问题。一个简单的解决方法是重命名您的资源。
回答by H.S.H
I had the same problem while using a third party library.
我在使用第三方库时遇到了同样的问题。
To solve it, I moved my ic_launcher.png files from drawable folder to mipmap folder. And problem solved.
为了解决这个问题,我将我的 ic_launcher.png 文件从 drawable 文件夹移动到了 mipmap 文件夹。问题解决了。
回答by shine_joseph
Adding aaptOptions.cruncherEnabled = false
in app.gradle solved mine
添加aaptOptions.cruncherEnabled = false
app.gradle 解决了我的问题
回答by Pablo Rocha
In case any one else has this problem and none of the mentioned answers solved your issue you can add this line to your AndroidManifest.xml file in the application tag:
如果其他人遇到此问题并且上述答案均未解决您的问题,您可以将此行添加到应用程序标记中的 AndroidManifest.xml 文件中:
tools:replace="android:icon
tools:replace="android:icon
You also need the tool namespace in you manifest tag
您还需要清单标签中的工具命名空间
xmlns:tools="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools"
So it would look like this:
所以它看起来像这样:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.sqlite" >`
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:icon"
android:icon="@mipmap/ic_launcher"
android:name="com.orm.SugarApp">
I have the com.github.satyan:sugar:1.3
dependency as well, I believe that library is importing another icon in its own manifest, thus causing the conflict.
我也有com.github.satyan:sugar:1.3
依赖性,我相信库正在其自己的清单中导入另一个图标,从而导致冲突。
回答by Pravinsingh Waghela
Simply Rename
the Image
(Rightclick on the Image, Select Refactor and select Rename
). It will solve the issue as the Issue has arise as one of the library/Module
is also using the image with the same name
.
Simply Rename
在Image
(Rightclick on the Image, Select Refactor and select Rename
)。它将解决问题,因为问题已经出现,因为其中之一library/Module
也在使用image with the same name
.