androidproguardminifyandroid-r8instrumented-test

Android Getting R8 error: Already has a mapping when trying to run UI tests with minified build


I want to be able to run UI tests on a minified build. However when I run

 ./gradlew connectedDebugAndroidTest

I get this error:

> Task :app:minifyDebugAndroidTestWithR8
R8: 'void zza(com.google.android.gms.common.internal.BaseGmsClient,int,android.os.IInterface)' already has a mapping

I tried creating a separate proguard file for the tests:

buildTypes {
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            testProguardFile 'proguard-test.pro'
# proguard-test.pro:
-include proguard-rules.pro
-keepattributes SourceFile,LineNumberTable
-dontobfuscate
-dontwarn
-dontshrink

But that didn't help. Not sure what else to try.


Solution

  • There has been a number of "Already has a mapping" issues (the most recent being issuetracker.google.com/140851070). All known issues of this kind has been fixed for Android Studio 4.2 (currently on preview, developer.android.com/studio/preview).

    One can also use AGP 4.2.0-rc01 without having to update Android Studio by using this dependency: com.android.tools.build:gradle:4.2.0-rc01 in the top level build.gradle file.