【问题标题】:Note: android.support.v4.app.NotificationCompatJellybean calls 'Field.getType'注意:android.support.v4.app.NotificationCompatJellybean 调用 'Field.getType'
【发布时间】:2015-10-11 23:14:13
【问题描述】:

我在我的 Android Studio 项目中使用 ProGuard。当我构建我的版本时,我得到以下注释:

Note: android.support.v4.app.NotificationCompatJellybean calls 'Field.getType'

这是我的 Gradle 配置:

proguardFiles getDefaultProguardFile('proguard-android.txt'),
            'proguard-rules.pro'

这里是 proguard-rules.pro:

-dontnote org.apache.http.conn.scheme.HostNameResolver
-dontnote org.apache.http.conn.**
-dontnote org.apache.http.params.**
-dontnote android.net.http.**

-dontnote **ILicensingService
-dontnote com.android.vending.billing.IInAppBillingService

我该如何解决这个笔记的问题?

【问题讨论】:

    标签: java android android-studio proguard android-proguard


    【解决方案1】:

    将以下行添加到您的 proguard-rules.pro 文件中:

    -keepattributes Signature
    

    解释:

    您的注释与 android.support.v4.app.NotificationCompatJellybean 无关,但与 Field.getType 无关。

    方法getType属于反射包的java.lang.reflect.Field,可能会访问Java类文件中存储的元信息。然而,这个元信息被 proguard 删除(没有上面的规则)——因此警告。

    另请参阅可与-keepattributes 一起使用的attributes。对于属性 Signature 表示如下:

    指定类、字段或 方法。编译器可能需要此信息才能正确编译 使用已编译库中的泛型类型的类。
    代码可以通过反射访问此签名。

    【讨论】:

      【解决方案2】:

      尝试将以下行添加到您的 ProGuard 配置中:

      -dontnote android.support.v4.app.NotificationCompatJellybean
      

      NotificationCompatJellybean 在其getExtras() 方法中获取私有Notification.extras 字段的类型。但是作为 Android SDK 中 Notification 类中的这个字段,您可以使用上面的命令忽略此注释。

      【讨论】:

        猜你喜欢
        • 2012-05-06
        • 1970-01-01
        • 1970-01-01
        • 2023-03-06
        • 2015-10-27
        • 2014-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多