I want to compile a project, I got 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.
here is the gradle file:
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?
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.
- In case you administrate your own aar files:
You have to ensure that your gradle and buildToolsVersion are identically in your project and the used aars.
- In case you use external libs where you can't control the gradle/build version:
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.
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
.
Adding aaptOptions.cruncherEnabled = false
in app.gradle solved mine
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:
tools:replace="android:icon
You also need the tool namespace in you manifest tag
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.
来源:https://stackoverflow.com/questions/27402048/android-studio-error-code-1-gradle-execution-failed-for-task-appprocessdeb