简体   繁体   中英

Is R8 not support applyMapping?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM