如何在我的Android库(AAR)中包含proguard配置 [英] How to include a proguard configuration in my Android library (AAR)

查看:464
本文介绍了如何在我的Android库(AAR)中包含proguard配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 AAR文件规范,Android库包含一个'proguard .txt'文件。
我的理解是,这个文件声明了库如何正确地被混淆和缩小。在我的情况下,我需要保留一些API类。



如何在库的build.gradle中声明库的proguard.txt文件?在创建使用我的库的应用程序(APK)时,该文件是否会自动读取?



我没有在Android的Gradle插件用户指南中找到这些信息。 p>

解决方案

在您的Gradle文件的默而不是 proguardFiles 。例如:

  defaultConfig {
consumerProguardFiles'proguard.txt'
}
code>


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 minified. In my case I need to preserve some API-classes.

How can I declare the library's proguard.txt file in the library's build.gradle? And will this file be automatically read when creating an application (APK) that uses my library?

I didn't find this information in Android's Gradle Plugin User Guide.

解决方案

In your Gradle file's default configuration closure, specify your Proguard file with consumerProguardFiles instead of proguardFiles. For example:

defaultConfig {
    consumerProguardFiles 'proguard.txt'
}

这篇关于如何在我的Android库(AAR)中包含proguard配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆