3

Android library: Try to run tests against obfuscated code

apply plugin: 'com.android.library'
android {
    buildTypes {
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

source sets

src/main/
src/androidTest

run tests:

gradle connectedAndroidTest

The classes.jar inside the mylib-debug.aar is obfuscated by proguard (as expected), but connectedAndroidTest is not running against proguarded code. I intentionally commented out some -keep in proguard-rules.pro, but no error occurs at runtime.

Looked at the test apk mylib-debug-androidTest.apk under build (not on device) , the classes inside the apk are not obfuscated. why? The classes inside mylib-debug.aar are obfuscated.

Update

I tried Android Unit Tests with proguard enabled

the answer is for app, not for android library. It did not work.

Update

How to configure connectedAndroidTest so that it includes the proguarded .aar and exclude the main output?

eastwater
  • 4,624
  • 9
  • 49
  • 118

0 Answers0