Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
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 | ||||
---|---|---|---|---|
| ||||
android { //... buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } |
Kotlin (build.gradle.kts)
Code Block | ||||
---|---|---|---|---|
| ||||
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: |