proguard gradle debug build but not the tests

后端 未结 3 1953
长情又很酷
长情又很酷 2020-12-05 15:37

I enabled proguard for the debug build using:

android {
    buildTypes {
        debug {
            runProguard true
            proguardFile \'proguard-deb         


        
3条回答
  •  不思量自难忘°
    2020-12-05 16:00

    runProguard is old. It was replaced with minifyEnabled

    With minifyEnabled (and other changes in new versions of gradle) you will may encounter issues where the proguard config works for your debug apk but not for the instrumentation tests. The apk created for instrumentation tests will use its own proguard file, so changing your existing proguard file will have no effect.

    In this case, you need to specify the proguard file to use on the instrumentation tests. It can be quite permissive because it's not affecting your debug and release builds at all.

        // inside android block
        debug {
            shrinkResources true  // removes unused graphics etc
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testProguardFile('test-proguard-rules.pro')
        }
    

提交回复
热议问题