14

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?

roger
  • 9,063
  • 20
  • 72
  • 119
  • 1
    try to change to drawable-hdpi\ic_launcher.png: – Sasha Dec 10 '14 at 13:22
  • 1
    The error 1 basically tells you that you have a duplicate file...Rename it or delete it. – Kostas Drak Dec 10 '14 at 13:22
  • 4
    @Sultan thanks a lot. I find the problem too. It because that I have duplicate file "ic_launcher.png" in a jar file. – roger Dec 12 '14 at 09:36
  • 1
    @KostasMatrix thanks a lot. I find the problem too. It because that I have duplicate file "ic_launcher.png" in a jar file. – roger Dec 12 '14 at 09:36

4 Answers4

13

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.

enter image description here

Hoshouns
  • 2,420
  • 23
  • 24
4
  • 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.

0xPixelfrost
  • 10,244
  • 5
  • 39
  • 58
  • +1 for renaming resources. Unfortunately doesn't work if multiple third party libraries have their own ic_launcher though. I ended up manually importing some of them and removing the ic_launcher inside my project as a result which is unfortunate but was unavoidable. – kha Jun 11 '15 at 20:02
  • rename the resources fixed my problem – mr.icetea Jun 18 '15 at 03:53
0

Adding aaptOptions.cruncherEnabled = false in app.gradle solved mine

shine_joseph
  • 2,922
  • 4
  • 22
  • 44
  • 1
    Hi. Please put some more information with your answer. i.e. the reason behind this issue. – V.J. Jul 24 '15 at 10:42
0

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.

Pablo Rocha
  • 530
  • 4
  • 9