I updated Android studio and if I'm correct the update includes R8 by default to my projects. The question is is r8 only activated by default on new projects or did the update include that change also to my already created project? If not how can I make use of it.
Asked
Active
Viewed 1.1k times
11
-
The update hopefully doesn't. It would likely break proguard. You can still easily toggle it though – Zoe Apr 24 '19 at 05:35
-
Everything just works fine. But why should it break proguard I thought v8 is replacing it so I would expect that proguard disappears completely – Yava Apr 24 '19 at 12:29
-
R8 can't replace proguard, because R8 is Google while Proguard is Guardsquare. Even in the unlikely event Google kills off Proguard support, Google has nothing to do with ProGuard, and therefore can't actually prevent it. ProGuard may be phased out as the standard, but it won't be replaced by R8. Also, while R8 has a compatibility mode with ProGuard, running both is likely gonna break stuff (that was what I meant by my last comment). Additionally, R8 currently [needs to be enabled manually](https://android-developers.googleblog.com/2018/11/r8-new-code-shrinker-from-google-is.html). – Zoe Apr 24 '19 at 13:21
-
Your link is from 2018 this one says "R8 enabled by default" at Behavior changes but I'm new to Android studio I don't understand mutch of it https://developer.android.com/studio/releases/gradle-plugin – Yava Apr 24 '19 at 13:24
-
`For a given build type, if you set useProguard to false in your app module's build.gradle file, the Android Gradle plugin uses R8 to shrink your app's code for that build type, regardless of whether you disable R8 in your project's gradle.properties file.` - suggests it doesn't override ProGuard. – Zoe Apr 24 '19 at 13:26
1 Answers
28
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.enableR8 = false
in gradle.properties; oruseProguard = true
in your build.gradle.
In Android Studio 3.5, the useProguard flag has no effect. That means that R8 is always used, unless you add android.enableR8=false
in gradle.properties.

Ian Zerny
- 336
- 3
- 4
-
Well, with at least one of my apps, R8 is not backwards compatible with Proguard. R8 stripped out resources I was using and my app would throw the following Exception: **java.lang.IllegalArgumentException: Resource not found: marker_default.png** I Couldn't figure out how to correctly modify the Proguard file for R8 so I used this solution. Now everything is working nicely the way it used to and my project's code is still minified and obfuscated. – user1608385 Jun 22 '19 at 02:50