I'm trying to test release build of Android app with Proguard turned on. I've created additional Proguard rules file for test dependencies which is included in the release rules file.
-keep class android.test.** { *; }
-dontwarn android.test.**
# Reuse the release ProGuard mapping
-applymapping proguard.map
-dontshrink
-dontoptimize
Everything compiles fine but it fails at runtime.
java.lang.NoSuchMethodError: android.test.AndroidTestRunner.addTestListener
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.start(ProGuard:135)
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner$BridgeTestRunner.start(ProGuard:249)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:389)
at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onCreate(ProGuard:114)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4702)
at android.app.ActivityThread.access$1600(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
I'm using Espresso for testing, the instrumentation runner is defined in build.gradle
defaultConfig {
testApplicationId 'package.name.test'
testInstrumentationRunner 'com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner'
}
Any chance to run tests for proguarded release build? I've found topic back from May and it looks like it's impossible. For me it looks like it's just wrong Proguard configuration (missing method), but the line -keep class android.test.** { *; }
should fix such issue. Am I missing something?