0

我最近使用 Google Play 服务和支持 V4 最新版本库将 proguard 添加到一个大型项目中。

我没有在 proguard 配置文件中添加任何关于这些库的内容,我只是添加了这个:

-ignorewarnings
-dontobfuscate

现在我注意到在 proguard 输出文件 usage.txt 中(您可以看到 proguard 删除的所有代码)中有很多来自 google play services 和 android support v4 的代码。

我检查了官方文档,如果您使用 proguard,我没有发现任何关于为 Support v4 和 google play 服务添加例外的信息,我刚刚发现:

注意:ProGuard 指令包含在 Play 服务客户端库中以保留所需的类。Gradle 的 Android 插件会自动将 ProGuard 配置文件附加到 AAR (Android ARchive) 包中,并将该包附加到您的 ProGuard 配置中。在项目创建期间,Android Studio 会自动创建 ProGuard 配置文件和 build.gradle 属性以供 ProGuard 使用。要将 ProGuard 与 Android Studio 结合使用,您必须在 build.gradle buildTypes 中启用 ProGuard 设置。有关详细信息,请参阅 ProGuard 指南。

但问题是我没有使用 Android Studio 编译,我使用 ant 和 eclipse 从命令行编译,我没有使用 gradle,所以我不确定是否必须在 proguard 配置文件中添加一些东西,我可以'在官方文档中找不到任何关于此的内容。

如果我不在这些库的 proguard 配置中添加一些东西,我将来会遇到问题吗?

4

1 回答 1

0

我有几个 v4 项目,并且在 proguard 配置中不需要任何特殊的东西。我唯一能找到的是

# Supporting compatibility library
-dontwarn android.support.**

如果删除它看起来不会有害。

更新

对于 Google Play 服务:

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}
于 2015-08-07T08:15:33.240 回答