3

I keep getting the error message "Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'."

According to stackoverflow question transformClassesAndResourcesWithProguardForRelease FAILED I need to just add the following code to my proguard-rules.pro:

-ignorewarnings
-keep class * {
    public private *;
}

Where do I find this proguard-rules.pro file? Do i need to create it myself and if so, whereabouts should I put in my app directory?

Jason Lloyd
  • 272
  • 5
  • 20

1 Answers1

11

First, we will enable shrinking in the build file. Find build.gradle file which sits inside /android/app/ folder and add lines in bold

android {

    ...

    buildTypes {

        release {
            
            signingConfig signingConfigs.debug     
            //add everything below
            useProguard true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 

        }
    }
}

Next, we will create a configuration that will preserve the entire Flutter wrapper code. Create /android/app/proguard-rules.pro file and insert inside:

-ignorewarnings
-keep class * {
    public private *;
}

DONE!

Yauhen Sampir
  • 1,839
  • 13
  • 16
  • i did your solution but got error i dont know why Caused by: groovy.lang.MissingMethodException: No signature of method: build_czlcicqqc0apz0tggwztw1w16.android() is applicable for argument types: – Adnan haider Sep 09 '21 at 10:12
  • 1
    when i remove useProguard true line then it work fine – Adnan haider Sep 09 '21 at 10:28