【问题标题】:Google Play Services and Support V4 with ProGuard... Problems?带有 ProGuard 的 Google Play 服务和支持 V4... 有问题吗?
【发布时间】:2015-08-07 07:27:52
【问题描述】:

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

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

-ignorewarnings
-dontobfuscate

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

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

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

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

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

【问题讨论】:

    标签: android google-play-services proguard android-proguard


    【解决方案1】:

    我有几个 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 *;
    }
    

    【讨论】:

    • 那么 Google Play 服务与 eclipse(没有 gradle)呢?
    • 你在哪里找到官方消息说如果你不使用 gradle 必须将这些代码行添加到 pro guard config 中?
    • 老实说,我现在找不到任何东西。我可以告诉你的是,它对我们使用 IAB 和 Google Analytics 很有效。
    • 我在没有为 Google Play 服务添加任何 proguard 配置行的情况下测试了 GCM 和 Admob,它正在工作,所以我不确定是否必须添加。我非常接近 android 的 65.000 方法限制,所以如果不是绝对必要,我无法增加我的方法计数
    猜你喜欢
    • 2017-09-01
    • 1970-01-01
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    相关资源
    最近更新 更多