【Android Gradle 插件】Android Library 依赖库混淆配置 ( ProductFlavor#consumerProguardFiles 配置 | 依赖库混淆配置 )

Android Plugin DSL Reference 参考文档 :





一、ProductFlavor#consumerProguardFiles 配置



ProductFlavor ( build.gradle#android#defaultConfig 配置 ) 文档 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.ProductFlavor.html


在 ProductFlavor 中的 consumerProguardFiles 配置 , 是用于配置 Library 依赖库的混淆文件的 ;


ProductFlavor#consumerProguardFiles 配置原型 :

List<File> consumerProguardFiles
ProGuard rule files to be included in the published AAR.
发布的AAR中要包含的ProGuard规则文件。

These proguard rule files will then be used by any application project that consumes the AAR (if ProGuard is enabled).
然后,使用AAR的任何应用程序项目都将使用这些proguard规则文件(如果启用了proguard)。

This allows AAR to specify shrinking or obfuscation exclude rules.
这允许AAR指定收缩或模糊排除规则。

This is only valid for Library project. This is ignored in Application project.
这仅对库项目有效。这在应用程序项目中被忽略。




二、依赖库混淆配置



Android 的 Application 主工程 经常需要 引用 Library 依赖库工程 ,

Library 依赖库工程 的源码 一般也需要进行混淆 ,

在 Library 工程中有 2 2 2 种方式配置混淆文件 ,

  • 方式一 : 在 android#buildTypes#release#proguardFiles 中配置混淆文件 ;
  • 方式二 : 在 android#defaultConfig#consumerProguardFiles 中配置混淆文件 ;

android#defaultConfig#consumerProguardFiles 中配置的混淆文件会传递给 引用该依赖库 的工程 ;

猜你喜欢

转载自blog.csdn.net/han1202012/article/details/124958132