android-testing-templates icon indicating copy to clipboard operation
android-testing-templates copied to clipboard

Test apk not getting shrinked (obfuscated)

Open rokos opened this issue 8 years ago • 3 comments

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.

rokos avatar Oct 11 '17 10:10 rokos

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).

TWiStErRob avatar Dec 20 '17 17:12 TWiStErRob

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 avatar Mar 31 '18 23:03 tir38

@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.

gebitang avatar Nov 13 '18 11:11 gebitang