How to obfuscated the code of an Android app in Android Studio

Oscar de la Hera Gomez
Two flowers that represent Kotlin and Android Studio. Beneath them sits the text "Obfuscate Code."

A step by step guide on obfuscating the code (R8/proguard) of an Android in Android Studio and Kotlin.

A screenshot of the Google Play Store with a warning that the code has not be obfuscated.

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

A screenshot of Android Studio showing the app level build.gradle.kts file with the updated code that is provided below.

At the app level build.gradle.kts, add the following code within the android section.

Step Two: Update the Build Number

A screenshot of the Google Play Store showing the error that is produced when you try to upload a build with the same 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.

A screenshot of Android Studio showing the app level build.gradle.kts file with the build number variables highlighted. Increment the version build by 1.

Step Three: Sync the Gradle

A screenshot of Android Studio showing a gradle file that has recently been modified. Highlighted is the "Sync Now" button that appears on the right of the prompt at the top of the Gradle file. Click this button to sync the gradle files with the project.

Sync the Gradle files.

Step Four: Clean and Rebuild

A screenshot of Android Studio show you how to clean your project. Highlighted is the Build menu and the Rebuild Project option.

Clean and rebuild the Android project.

Step Five: Generate a new Android App Bundle

A screenshot of Android Studio highlighting the Build menu as well as the Generate Bundle / APK menu option.

Generate a new Android App Build (.aab) to upload to the Google Play Store.

Step Six: Test

A screenshot of the Google Play Store with the new build uploaded demonstrating that the warning has dissapeared.

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.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details