18

I'm getting deprecated warnings in regards to Proguard as well as R8 after upgrading my Android Studio to 3.6. Does that mean we shouldn't use obfuscation in our projects or is there another equivalent option we should consider while building in release mode?

The option 'android.enableR8' is deprecated and should not be used anymore. It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8. Affected Modules: etc

Eric
  • 1,685
  • 1
  • 17
  • 32
  • Can you please share the messages that you are getting? – Anton Baranenko Feb 25 '20 at 15:28
  • Can you clarify what you mean by "deprecated warnings" in this context? The actual text of the warnings could help. – Peter Tefft Feb 25 '20 at 15:28
  • I don't remember exact message, but it said it's being deprecated. Side note: I've got it after upgrading to Android Studio 3.6 – Eric Feb 25 '20 at 19:11
  • To get an answer you should post the _full, exact_ warning message. For example, the `useProGuard` setting has been deprecated a while ago - maybe that's what you saw and you're misremembering it. – Michael Feb 25 '20 at 19:22
  • I've been switching to R8 this week and removing all `useProGuard` from my gradle's – Eric Feb 25 '20 at 19:28
  • Ok, message copy-pasted – Eric Feb 25 '20 at 19:29
  • As the messages states, only ProGuard will be deprecated. Obfuscation will be there, using R8. The *switch* for the deprecated ProGuard is deprecated as well. – Michiel Feb 25 '20 at 20:07

1 Answers1

17

Does that mean we shouldn't use obfuscation in our projects

No. You can use obfuscation and optimization tooling.

is there another equivalent option we should consider while building in release mode

If you have android.enableR8 = true in your gradle.properties, remove it as R8 it the default tooling and the android.enableR8 setting itself is deprecated, causing these deprecation warnings.

If you have android.enableR8 = false to use proguard for optimiation and obfuscation, consider migrating to R8 instead.

laalto
  • 150,114
  • 66
  • 286
  • 303
  • how to make the project obfuscate? I removed all the given properties and said to remove the dependency of R8 from build.gradle and i can't compile the project anymore, i get R8NullPointerException what's that? – Lena Bru Feb 27 '20 at 12:31
  • That looks like something beyond the scope of comment section here. – laalto Feb 27 '20 at 12:33
  • @laalto What I got from your answer is that R8 will work automatically so no need to add `android.enableR8 = true`, right? – Mohamed Mar 20 '20 at 08:14
  • @Mohamed That's my understanding too, provided that you have Android Gradle plugin 3.6 or newer. – laalto Mar 20 '20 at 08:27
  • 2
    That is promised proguard configuration should be 100% compatible with new R8. Unfortunately, R8 has completly destroyed my release build and it looks like most ProGuard rules were just ignored. As I have no time for any further analysing, I am stuck to use ProGuard, sad news in Gradle 7.0 it won't be possible to disable R8. So I don't think I am going to update my project to Gradle 7.0 when available – user1209216 Jun 01 '20 at 09:44
  • Is there a way where in build.gradle if we can specify any obfuscation tool that is used from our side and hence don't want R8 obfuscation on top of it? – Shrimantee Roy Jul 02 '20 at 11:07
  • @user1209216 are you sure enableR8 will not work in Gradle 7.0? Can you please share your source for this info? – Markymark Oct 15 '20 at 22:04
  • No need to share anything, just read warning message - it says Gradle 5.0 will remove ability to disable R8: `WARNING: The option setting 'android.enableR8=false' is deprecated. It will be removed in version 5.0 of the Android Gradle plugin. You will no longer be able to disable R8` – user1209216 Oct 16 '20 at 09:13