4

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
  • 378
  • 7
  • 23

1 Answers1

14

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,989
  • 15
  • 16