Releasing Your App
Follow these steps to prepare and release your Android app properly:
Update the proguard-rules.pro File
When you are ready to release your app, the first thing to do is update your proguard-rules.pro file.
Navigate to your project directory:
App/android/app/Open the
build.gradle.ktsfile.
Verify or Add ProGuard Configuration
Scroll to the
buildTypessection.Check whether the ProGuard configuration has been added.
If it’s missing, add the following lines:
buildTypes { getByName("release") { ... ... // Verify this configuration in your build.gradle file proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) signingConfig = signingConfigs.getByName("debug") } }Ensure that the
proguard-rules.profile exists in theApp/android/app/directory.If it doesn’t exist, create it manually.
Build the Release APK
Run the following command to build your release APK and verify that all required properties are properly configured:
flutter build apkResolve R8 Compilation Errors (If Any)
If you encounter an error such as the following:
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /build/app/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class com.google.devtools.ksp.processing.SymbolProcessorProvider (referenced from: com.squareup.moshi.kotlin.codegen.ksp.JsonClassSymbolProcessorProvider)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to completeDo the following:
Navigate to the file path below:
build/app/outputs/mapping/release/missing_rules.txtCopy the rules listed in this file.
Paste them into your
proguard-rules.profile.
Rebuild and Verify
After updating the ProGuard rules, run the release command again to ensure all issues are resolved:
flutter build apkIf the build completes successfully, your app is ready for release.
Last updated