How to include a proguard configuration in my Android library (AAR)

后端 未结 2 1556
情歌与酒
情歌与酒 2020-12-05 18:26

Android libraries, per the AAR file spec, includes a \'proguard.txt\' file. My understanding is that this file declares how the library correctly can be obfuscated and mini

2条回答
  •  [愿得一人]
    2020-12-05 18:41

    If you create library you can disable proguard and provide a consumerProguardFiles in you build.gradle which will be used by consumer project which resolve it

    android {
        defaultConfig {
            consumerProguardFiles 'proguard-rules.pro'
        }
    
        buildTypes {
            release {
                minifyEnabled false
            }
        }
        //...
    }
    

    But if you should enable proguard, for example, because you want distribute your library as archive - you are able to use the next possibility:

    android {
    
        buildTypes {
            release {
                minifyEnabled true
                proguardFiles 'proguard-rules.pro'
            }
        }
        //...
    }
    

提交回复
热议问题