How to Prevent Conflicts with ProGuard in Android Apps

Last updated November 29, 2023 by Appdome

This article provides important information about the compatibility issues between ProGuard and some of Appdome’s protections. If Appdome users attempt to upload mobile applications containing ProGuard, the upload will be blocked, and you will receive a message prompting you to disable ProGuard before proceeding. This is done specifically to avoid specific conflicts that certain ProGuard protections can cause if you attempt to implement Appdome.

What is ProGuard?

ProGuard is an open-source command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods in an Android app.

Why Can’t I Use ProGuard and Appdome in the same app?

In certain cases, ProGuard can collide with Appdome’s implementation of Obfuscate App Logic. Therefore, whenever an app is recognized as having ProGuard, Appdome does the following:

  • Shows a visual indication in the app preview.
    Prevent conflicts with Proguard SDK
  • Displays an additional alert inside the Build Tab which instructs the user how to resolve the conflict by removing ProGuard from their app. Prevent conflicts with Proguard sdK

How to Disable ProGuard with Groovy

  1. Got to the build,gradle of your app
  2. Mark the minifyEnabled and shrinkResources configurations as “false”

Note: If you require additional information, please refer to this developer guide on how to Shrink, obfuscate, and optimize your app

android {
    buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type. Make sure to use a build
            // variant with `debuggable false`.
            minifyEnabled false

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources false

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
    ...
}

How to Disable ProGuard with Kotlin

  1. Got to build,gradle of your app
  2. Mark the minifyEnabled and shrinkResources configurations as “false”
android {
    ...
    buildTypes {
        getByName("release") {
            isShrinkResources = false
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android.txt"),
                "proguard-rules.pro"
            )
        }
    }
}

 

Related Articles:

Thank you!

Thanks for visiting Appdome! Our mission is to secure every app on the planet by making mobile app security easy. We hope we’re living up to the mission with your project.

Appdome

NEED HELP?

let's solve it together

GilMaking your security project a success!
By filling out this form, you opt-in to receive emails from us.