Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconIde56cc10c-bd63-4d4d-abf2-36035235d240atlassian-info
panelIcon:Android:panelIconText:Androidinfo:
bgColor#E3FCEF

The purpose of obfuscation is to reduce your app size by shortening the names of your app’s classes, methods, and fields.

Table of Contents
minLevel1
maxLevel6
outlinefalse
styledefault
typelist
printablefalse

...

ProGuard

Android ProGuard is a tool to obfuscate, shrink, and optimize your code. Obfuscated code can be more difficult for other people to reverse engineer. ProGuard renames classes, fields, and methods with semantically obscure names and removes unused code.

...

PLEASE NOTE:

When building your project using Android Gradle plugin 3.4.0 or higher, the plugin uses the R8 compiler, instead of ProGuard, to handle the following compile-time tasks:

  • Code shrinking (or “Tree-Shaking”)

  • Resource shrinking

  • Obfuscation

  • Optimization

Turn on ProGuard for release builds in the build.gradle file of the app

Groovy (build.gradle)

Code Block
breakoutModewide
languagegroovy
android {
    //...
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Kotlin (build.gradle.kts)

Code Block
breakoutModewide
languagekotlin
android {
    //..
    buildTypes {
        getByName("release") {
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }
}

Add ProGuard exceptions for the Anyline SDK

To add an exception for the Anyline SDK, you have to add the following lines to your ProGuard config file. In case you used the configuration from the example above, your ProGuard file is called proguard-rules.pro.

...

PLEASE NOTE:

-keep specifies classes and class members (fields and methods) to be preserved as entry points to your code. 

...

Further Information

Info

Should you wish to read more about how shrinking, obfuscating and optimizing your app, please find the Android Developer Documentation Page below:

https://developer.android.com/build/shrink-code