11

When I try to generate signed in Android Studio, I've got the following error :

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. java.io.IOException: Please correct the above warnings first.

Already make some research and find that for example :

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

I followed the advice, it didn't works. So, I tried to update my buildToolsVersion to 23.0.2.

Didn't work too.

It's works only when I modify minifyEnabled to false, and I don't want to.

Can you give me a track please ?

Community
  • 1
  • 1
fabienbranchel
  • 494
  • 1
  • 6
  • 21

4 Answers4

12

Try performing a clean build (Build > Clean Project) and buliding again.

If that doesn't work, it's likely Proguard is removing some important classes and/or libraries in your app. Take a look at the warnings generated above the error message in the log. You'll need to add rules to your proguard-rules.pro file to keep the necessary classes. Here is an example of the rules required to keep the Butterknife library.

Colin White
  • 1,041
  • 11
  • 22
  • 3
    Fault to JodaTime. Just had this : `-dontwarn org.joda.time.**` to my proguard-rules.pro file, it's works. Thank you really really much Colin, drinks on me ;-) – fabienbranchel Mar 14 '16 at 19:55
1

I had this error, and I don't know why it happened.

I have tried lot of solutions without success.

Except adding these lines to my ProGuard file (proguard-rules.pro) :

-ignorewarnings

-keep class * {
    public private *;
}

Then Clean and Rebuilt, then generate release apk.

Thanks to Rahul...

Christian
  • 748
  • 7
  • 23
  • Thanks - after frigging around with 'version' compatibility around gradle this was actually the fix for me. – Harv Jan 11 '19 at 11:31
  • Note that this directive will prevent proguard from removing any unused classes, which may greatly increase the size of your app. You may want to consider using a more targeted directive (for example, only keeping the package that is causing the original error). – Nic Dahlquist Apr 28 '19 at 04:47
0

Add this line in proguard-rules.pro

-keepattributes EnclosingMethod
Muhammad Usman Ghani
  • 1,279
  • 13
  • 19
0

Update your Gradle plugin and it will work.

Nouman Ghaffar
  • 3,780
  • 1
  • 29
  • 37