Skip to content Skip to sidebar Skip to footer

D8 Desugaring: Unexpected Type Adjustment

I enable the new D8 desuaring in Android Studio 3.1.3 in my gradle.properties: android.enableD8.desugaring=true Now the compilation fails with this error in one of the java-only m

Solution 1:

Although the reason could be any depends on project I want to share the way I have fixed such error:

  1. rename failing jar to zip
  2. run D8 directly on it, something like D:\Development\Tools\android-sdk\build-tools\28.0.2\d8.bat D:\Development\<PROJECT_PATH>\build\intermediates\intermediate-jars\debug\classes.jar.zip
  3. remove classes one by one from zip and go back step 2 until exception is gone

To speed up the process I was removing files in bulk to narrow down to the package and then to the exact file causing D8 failure.

As it turned out it was the following code (I'm using com.annimon.stream.Stream):

Stream.of(SOME_MAP).map(Map.Entry::getValue).findFirst().orElse(null);

where SOME_MAP is HashMap<String, String[]> and workaround was to use

Stream.of(SOME_MAP).map(entry -> entry.getValue()).findFirst().orElse(null);

Post a Comment for "D8 Desugaring: Unexpected Type Adjustment"