Android - 应用程序导出错误与proguard和谷歌播放服务

时间:2014-07-31 14:27:21

标签: android google-play-services proguard

我已将最新的Google Play服务添加到该项目中,现在正在进行中 我发出很多警告:

[2014-07-31 17:21:50 - MyApp] Proguard returned with error code 1. See console
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.common.SupportErrorDialogFragment: can't find referenced method 'void setShowsDialog(boolean)' in class com.google.android.gms.common.SupportErrorDialogFragment
[2014-07-31 17:21:50 - MyApp] Warning: com.google.android.gms.common.api.d: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class com.google.android.gms.common.api.d
[2014-07-31 17:21:50 - MyApp]       You should check if you need to specify additional program jars.
[2014-07-31 17:21:50 - MyApp] Warning: there were 9 unresolved references to classes or interfaces.
[2014-07-31 17:21:50 - MyApp]          You may need to specify additional library jars (using '-libraryjars').
[2014-07-31 17:21:50 - MyApp] Warning: there were 2 unresolved references to program class members.
[2014-07-31 17:21:50 - MyApp]          Your input classes appear to be inconsistent.
[2014-07-31 17:21:50 - MyApp]          You may need to recompile them and try again.
[2014-07-31 17:21:50 - MyApp]          Alternatively, you may have to specify the option 
[2014-07-31 17:21:50 - MyApp]          '-dontskipnonpubliclibraryclassmembers'.
[2014-07-31 17:21:50 - MyApp] java.io.IOException: Please correct the above warnings first.
[2014-07-31 17:21:50 - MyApp]   at proguard.Initializer.execute(Initializer.java:321)
[2014-07-31 17:21:50 - MyApp]   at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-07-31 17:21:50 - MyApp]   at proguard.ProGuard.execute(ProGuard.java:86)
[2014-07-31 17:21:50 - MyApp]   at proguard.ProGuard.main(ProGuard.java:492)

我尝试过添加

-dontwarn com.google.android.gms.*
-keep class android.support.v4.** { *; }

到proguard配置fil但没有运气。我在我的应用程序中瞄准了android 17(4.2.2),而min SDK版本是8(我认为是2.2)。

任何有助于解决此错误的帮助都将受到赞赏。

3 个答案:

答案 0 :(得分:4)

确保您已使用Android 4.4.2设置项目,并且“包含android-support-v13.jar”。我有同样的问题,但现在已经解决了。

答案 1 :(得分:1)

你添加了:

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

在你的Proguard? http://developer.android.com/google/play-services/setup.html

答案 2 :(得分:1)

似乎google play服务jar正在引用android-support-v13.jar中的一些类。 因此在proguard-project.txt中添加以下行将解决问题:

-libraryjars <ANDROID_SDK_PATH>/extras/android/support/v13/android-support-v13.jar

您需要使用Android SDK管理器下载此jar。