Error:Execution failed for task ':android:transformClassesAndResourcesWithProguardForRelease'

74,551

Solution 1

This bug happens when the versions of SDK, Build Tools and Gradle Plugins doesn't match (in terms of compatibility). The solution is to verify if you are using the latest versions of them. The gradle plugins are placed in the build.gradle file of the project. Other versions are in the build.gradle file of the module. For example, for SDK 23, you must use the Build Tools 23.0.1 and gradle plugins version 1.3.1.

Clean the project after changing settings. (Solved my problem, and never seen it again.)

refer this question

Solution 2

Remove lines from proguard-rules.txt that contains:

-injars, -outjars, or -libraryjars

and rebuild.

Solution 3

Removing minifyEnabled true from release config worked for me.

Solution 4

in my case it was okhttp proguard rules after adding them it worked fine

#OKhttp RULES START
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
#OKhttp RULES END

#picasso rules START
-dontwarn com.squareup.okhttp.**
#picasso rules END
Share:
74,551
Z0q
Author by

Z0q

Updated on July 09, 2022

Comments

  • Z0q
    Z0q almost 2 years

    Every time I am getting this error when running my project. I can do a Clean and then Run again, and it works. But it is not an optimal solution. Any ideas?

    Error:Execution failed for task ':android:transformClassesAndResourcesWithProguardForRelease'.
    

    java.io.IOException: Failed to rename android\build\intermediates\transforms\proguard\release\folders\3\1f\main\classes.jar to android\build\intermediates\transforms\proguard\release\jars\3\1f\classes.jar

  • Sohayb Hassoun
    Sohayb Hassoun almost 8 years
    I tried it with SDK 24, Build Tools 24.0.0 and gradle plugin version 2.1.2, I'me having the same problem..
  • box
    box over 7 years
    @sohayb Perhaps you have an issue in your proguard file with some of the 3rd party libraries? That happened in my case...I just added the correct rules for the external library and it was sufficient.
  • VolkanCetinkaya
    VolkanCetinkaya almost 7 years
    minifyEnabled to false = disabled proguard
  • Awadesh
    Awadesh almost 7 years
    Hi I also have the same problem , can you help, for the issue please follow this link stackoverflow.com/questions/45629710/…
  • salvi shahzad
    salvi shahzad over 5 years
    where can the proguard-rules.txt file be found?
  • salvi shahzad
    salvi shahzad over 5 years
    I am using: compileSdkVersion 27, buildToolsVersion "27.0.3", minSdkVersion 16, targetSdkVersion 25 and gradle plugin version 3.0.1 I am facing the same problem. What should I do?
  • imaginabit
    imaginabit over 5 years
    same problem @salvishahzad actually you dont need the "buildToolsVersion" so you can comment that line and android get the version that works with gradle in my case i can solve the problem adding --dontwarn retrofit2.Platform$Java8 like in stackoverflow.com/questions/36010942/…
  • Sanche
    Sanche about 5 years
    Add this line in your proguard-rules.pro file to fix this problem . @salvishahzad -ignorewarnings
  • Ali Akram
    Ali Akram about 5 years
    In my case Issue was : "The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.1"
  • angelos_lex
    angelos_lex about 5 years
    @salvishahzad in my case: android/app/proguard-rules.pro
  • petrov
    petrov over 2 years
    I think that's only a temporary solution for someone who is not wanted to do it. like disable R8, or not using proguard