Google Play Services v23 Proguard配置

时间:2015-04-18 09:33:24

标签: android google-play-services proguard

升级到Google Play服务v23后,我在尝试在Eclipse中导出已签名的应用程序时看到此消息:

Proguard returned with error code 1. See console
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller$SessionInfo
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller$SessionInfo
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'android.content.pm.PackageInstaller getPackageInstaller()' in class android.content.pm.PackageManager
Warning: com.google.android.gms.internal.zzif: can't find referenced method 'void setMixedContentMode(int)' in class android.webkit.WebSettings
      You should check if you need to specify additional program jars.
Warning: there were 4 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars').
Warning: there were 2 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile them and try again.
         Alternatively, you may have to specify the option 
         '-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
    at proguard.Initializer.execute(Initializer.java:321)
    at proguard.ProGuard.initialize(ProGuard.java:211)
    at proguard.ProGuard.execute(ProGuard.java:86)
    at proguard.ProGuard.main(ProGuard.java:492)

我按照documentation

中的说明添加了此内容
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-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 *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

并尝试添加

-keep class android.content.pm.PackageInstaller.**

proguard-project.txt,但这并没有帮助。

我错过了什么?

4 个答案:

答案 0 :(得分:46)

嘿,我有完全相同的错误,我通过添加:

修复它
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**

到我的proguard.cfg

答案 1 :(得分:11)

我遇到了同样的问题,但使用Android Studio。基于Lary Ciminera的解决方案,我添加了

-dontwarn com.google.android.gms.**

到proguard-project.txt。

答案 2 :(得分:6)

我通过将它添加到proguard-project.txt:

来修复它
-keep class android.content.pm.PackageInstaller
-keep class android.content.pm.PackageInstaller$SessionInfo
-keep class android.content.pm.PackageManager

-dontwarn android.content.pm.PackageInstaller
-dontwarn android.content.pm.PackageInstaller$SessionInfo
-dontwarn android.content.pm.PackageManager

-keep class android.webkit.WebSettings
-dontwarn android.webkit.WebSettings

答案 3 :(得分:2)

将目标SDK版本升级到至少21可以解决此问题。 API版本21中添加了PackageInstaller和关联的类:https://developer.android.com/reference/android/content/pm/PackageInstaller.html