0

Use applyMapping will lead to a compile exception, like:

R8: 'boolean readField(int)' already has a mapping

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.

    com.android.tools.r8.CompilationFailedException: Compilation failed to complete

My Android Gradle Plugin's version is 3.5.3, I find it's a question of R8. Because when disable R8, applyMapping work fine, enable the R8, it will not work. I fond that the Mapping.txt generated by R8 has the duplicate methods like this:

1:1:boolean readField(int):0 -> a
2:2:boolean readField(int):0:0 -> a

If remove one of them, it will work fine.

xcxj
  • 1

1 Answers1

0

You are using an older version of R8 that too eagerly reports error in the mapping file. Try to use an older version by adding the following to your top-level build.gradle file:

buildscript {

repositories {
    maven {
        url 'http://storage.googleapis.com/r8-releases/raw'
    }
}

dependencies {
    classpath 'com.android.tools:r8:1.6.60'          // Must be before the Gradle Plugin for Android.
    classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
 }

}

This should help out with your issue.

MortenKJ
  • 296
  • 3
  • 3