android-testing-templates
android-testing-templates copied to clipboard
Test apk not getting shrinked (obfuscated)
If you try to minify (proguard) debug build by un-commenting :
debug {
// Run code coverage reports by default on debug builds.
testCoverageEnabled = true
// Uncomment this to run test against a minified version of the production APK
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFile 'proguard-test-rules.pro'
}
in app's build.gradle, *-androidTest.apk doesnt get obfuscated and method count is not reduced.
I tried 2.2.1 (what this repo has right now) and 3.0.1 (upgraded the repo) and it both works.
For me it didn't work though, and the reason seems to be because I was trying to apply it to a library module (https://issuetracker.google.com/issues/70901453).
I had the same issue as @rokos. It wasn't limited to library module though as was the case for @TWiStErRob . I filed a bug for it: https://issuetracker.google.com/issues/37134017
A google engineer responded:
Regarding the current issue: We do run Proguard but do not shrink code for test APKs. We use Proguard only to apply the mapping of the obfuscation of the tested app. This is a decision we made a few years ago.
Related bug: https://code.google.com/p/android/issues/detail?id=77475 Change: https://android-review.googlesource.com/#/c/119684/
So it looks like the documentation in this repo is actually wrong.
@tir38 Thanks.
I googled around the whole day, and found your question on SO.
I think you are right. Proguad doesn't work for test app. both your reported bug and this one say the same issue.