5

I have upgraded my Android project to use the latest Android Studio 3.0 features. Since then, I am getting the following warning message on each Gradle sync:

Warning:One of the plugins you are using supports Java 8 language features. To try the support built into the Android plugin, remove the following from your build.gradle: apply plugin: 'dexguard' To learn more, go to https://d.android.com/r/tools/java-8-support-message.html

If I go to the linked URL, I can see:

If Android Studio detects that your project is using Jack, Retrolambda, or DexGuard, the IDE uses Java 8 support provided by those tools instead.

There are migration docs for Jack and Retrolambda, but none for DexGuard.

My questions are:

  • Can I remove the DexGuard plugin and it will still work as expected?
  • If no, how should I go around resolving this warning?

I am running Android Studio 3.0 and DexGuard 8.0.16

Daniel Zolnai
  • 16,487
  • 7
  • 59
  • 71

1 Answers1

0

You are probably using Dexguard for code obfuscation, encryption or tamper detection. So removing it will remove those functionalities. You should try out the 8.0.17 release of dexguard and remove retrolamb, Jack and the Dexguard-java8 plugin from your build config.

On my app this seems to keep working, on 8.0.15/8.0.16 I still had to enable dexguard-java8 to have it working.

in your app build.gradle add this to enable java8 compiling.

apply plugin: 'dexguard'
...
android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

In your project.gradle just add

buildscript {
  repositories {
    flatDir { dirs 'dexguard' }
    ...
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath ':dexguard:'
    ...
  }
}

and make sure there are no references to retrolambda or dexguard-java8 in your gradle files and everything should work fine.

Aegis
  • 5,761
  • 2
  • 33
  • 42
  • How did you specifically use the java8 version? – Daniel Zolnai Nov 02 '17 at 15:28
  • Check the examples in my answers – Aegis Nov 02 '17 at 16:30
  • 1
    I have the exact same configuration, and I still get the warning on sync with the 8.0.17 version – Daniel Zolnai Nov 06 '17 at 14:32
  • those are just warnings. if the app installs and runs all devices you're targeting it can be ignored. – Aegis Nov 07 '17 at 08:35
  • I am using dexguard-8.1 and android studio fails to build throwing errors: Warning:One of the plugins you are using supports Java 8 language features. To try the support built into the Android plugin, remove the following from your build.gradle: apply plugin: 'dexguard' To learn more, go to https://d.android.com/r/tools/java-8-support-message.html Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing ActivityName.class file. Any help would be appreciated. – Namrata Bagerwal Mar 15 '18 at 13:14
  • 1
    I was also getting this error: Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process ProjectPath\...\build\intermediates\transforms\instantRun...\... Disabling 'Instant Run' rescued me. – Namrata Bagerwal Mar 16 '18 at 10:22