Android Studio: Error Code 1: Gradle: Execution failed for task ':app:processDebugResources'

33,001

Solution 1

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

Solution 2

  • 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.

Solution 3

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.

Share:
33,001
roger
Author by

roger

Updated on November 04, 2020

Comments

  • roger
    roger over 3 years

    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?

  • kha
    kha almost 9 years
    +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.
  • mr.icetea
    mr.icetea almost 9 years
    rename the resources fixed my problem
  • martyglaubitz
    martyglaubitz almost 9 years
    weird. this solved it for me to but still i'd love to know why this is happening at all...
  • V.J.
    V.J. almost 9 years
    Hi. Please put some more information with your answer. i.e. the reason behind this issue.