In my case, **testProguardFile("your-file.pro")** does not work at all (Don't know why!!!)
So I use below (Groovy) configuration for Stage build type, to ignore obfuscation of the automation test APK.
Original answered by https://stackoverflow.com/a/72187366/1377819
```
javastage {
initWith buildTypes.release
signingConfig signingConfigs.dev
// Disable minification ONLY when building the Test APK
minifyEnabled !gradle.startParameter.taskNames.any { it.contains("AndroidTest") }
// Disable shrinkResources ONLY when building the Test APK
shrinkResources !gradle.startParameter.taskNames.any { it.contains("AndroidTest") }
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
```
Don't know how to format code in the comment section, so I post it as an answer here (thank to Vin Normal solution)
In my case, **testProguardFile("your-file.pro")** does not work at all.
So I use below (Groovy) configuration for Stage build type, to ignore obfuscation for AndoidTest APK build.
```
stage {
initWith buildTypes.release
signingConfig signingConfigs.dev
// Disable minification ONLY when building the Test APK
minifyEnabled !gradle.startParameter.taskNames.any { it.contains("AndroidTest") }
// Disable shrinkResources ONLY when building the Test APK
shrinkResources !gradle.startParameter.taskNames.any { it.contains("AndroidTest") }
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
```