How to obfuscated the code of an Android app in Android Studio
A step by step guide on obfuscating the code (R8/proguard) of an Android in Android Studio and Kotlin.
The following tutorial shows how to fix the warning that appears on Google Play Store when releasing an internal or production build that has no obfuscated code.
Step One: Add the Code
At the app level build.gradle.kts, add the following code within the android section.
Step Two: Update the Build Number
The Google Play Store will produce this error if you do not do this step.
To make sure the Google Play Store accepts the new build, increment the app versionBuild number at the top of the app level build.gradle.kts.
Step Three: Sync the Gradle
Sync the Gradle files.
Step Four: Clean and Rebuild
Clean and rebuild the Android project.
Step Five: Generate a new Android App Bundle
Generate a new Android App Build (.aab) to upload to the Google Play Store.
Step Six: Test
Upload the new build to Google Play Store and confirm the warning has dissapeared.
Looking to customize what code gets obfuscated?
Add paths to your app level pro guard-rules.pro to stop files or directories from being obfuscated.