Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off only the obfuscation in Android R8?

Tags:

I use Android Studio 3.3 Canary 5, Gradle 4.9, gradle plugin 3.3.0-alpha05

minifyEnabled true useProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 

Does't work.


Edit:

@JakeWharton: "You use ProGuard configurations for this, not a Gradle DSL. Disable shrinking with -dontshrink, disable obfuscation with -dontobfuscate, and disable optimization with -dontoptimize."

TLDL

proguard-rules.pro

-dontshrink -dontobfuscate -dontoptimize 
like image 461
norbDEV Avatar asked Aug 15 '18 14:08

norbDEV


People also ask

What is R8 obfuscation?

Enable shrinking, obfuscation, and optimization 0 and higher, R8 is the default compiler that converts your project's Java bytecode into the DEX format that runs on the Android platform. However, when you create a new project using Android Studio, shrinking, obfuscation, and code optimization is not enabled by default.

Is R8 enabled by default?

In Android Studio 3.4, R8 is used by default for all projects that don't disable it. You can switch to Proguard with: android.

Should I use R8 or ProGuard?

R8 is having a faster processing time than Proguard which reduces build time. R8 gives better output results than Proguard. R8 reduces the app size by 10 % whereas Proguard reduces app size by 8.5 %. The android app having a Gradle plugin above 3.4.


2 Answers

In your gradle.properties file, add this line

 android.enableR8=false 

This worked for me.

like image 169
Bharath Avatar answered Sep 16 '22 16:09

Bharath


Following this answer, I was able to solve this issue. Instead of editing the build.gradle file, I added -dontobfuscate to the proguard-rules.pro file. (You can configure a different proguard rules file for debug and release builds.) This skipped the obfuscation step and allowed me to make shrink'd debug builds with R8.

like image 23
eli Avatar answered Sep 16 '22 16:09

eli