Integrating Espresso with Proguard and Gradle Integrating Espresso with Proguard and Gradle android android

Integrating Espresso with Proguard and Gradle


Here's what worked for me:

In build.gradle I added this line to my defaultConfig section:

testProguardFile "test-proguard-rules.pro"

Then I created test-proguard-rules.pro with the following contents:

-dontobfuscate-dontwarn

This tells gradle to use this separate proguard configuration for your test apk, the one containing your instrumentation tests. In this case you are telling proguard to not obfuscate your test apk, which is probably what you want. The main apk you are testing still gets obfuscated using your existing proguard config.


Do not proguard your apk(s) during testing, unless you absolutely have to.