0

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.

odiggity
  • 1,496
  • 16
  • 29
  • On which version of Android Studio/AGP do you see this issue? There has been a number of issues fixed in this area, that latest being https://issuetracker.google.com/140851070. Could you perhaps try with the latest Android Studio 4.2 (https://developer.android.com/studio/preview)? You can also just 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 yout top level `build.gradle`file. If that does not fix the issue please file a bug at https://issuetracker.google.com/issues/new?component=326788. – sgjesse Apr 08 '21 at 07:28
  • That seems to have fixed it, thanks @sgjesse! – odiggity Apr 08 '21 at 23:11

1 Answers1

1

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.

sgjesse
  • 3,793
  • 14
  • 17