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

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

问题描述

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

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.

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

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?

我在 Android 的 Gradle 插件用户指南中没有找到此信息.

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

推荐答案

在 Gradle 文件的默认配置闭包中,使用 consumerProguardFiles 而不是 proguardFiles 指定 Proguard 文件.例如:

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天全站免登陆