简体   繁体   English

使用Proguard构建Android APK并找到未找到的类异常

[英]Building Android APK with Proguard and getting a Class not found Exception

I have been trying to create an Android APK with proguard. 我一直在尝试使用proguard创建一个Android APK。 The application works when installed, but the minute it attempts to use an object from com.google.android.gms.common.images.ImageManager, it throws the following exception. 该应用程序在安装后可以正常工作,但是在尝试使用com.google.android.gms.common.images.ImageManager中的对象的那一刻,它引发了以下异常。 Im trying to use this class for use with Google Play Game Services. 我试图将此类用于Google Play游戏服务。

07-23 01:01:32.382: E/Parcel(615): Class not found when     unmarshalling:com.google.android.gms.common.images.ImageManager$b, e: java.lang.ClassNotFoundException: com.google.android.gms.common.images.ImageManager$b
07-23 01:01:32.387: E/AndroidRuntime(615): FATAL EXCEPTION: main
07-23 01:01:32.387: E/AndroidRuntime(615): java.lang.RuntimeException: Unable to start receiver com.google.android.gms.common.images.ImageBroadcastReceiver: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.common.images.ImageManager$b
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2287)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.app.ActivityThread.access$1600(ActivityThread.java:140)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Looper.loop(Looper.java:137)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.app.ActivityThread.main(ActivityThread.java:4938)
07-23 01:01:32.387: E/AndroidRuntime(615):  at java.lang.reflect.Method.invokeNative(Native Method)
07-23 01:01:32.387: E/AndroidRuntime(615):  at java.lang.reflect.Method.invoke(Method.java:511)
07-23 01:01:32.387: E/AndroidRuntime(615):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
07-23 01:01:32.387: E/AndroidRuntime(615):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
07-23 01:01:32.387: E/AndroidRuntime(615):  at dalvik.system.NativeStart.main(Native Method)
07-23 01:01:32.387: E/AndroidRuntime(615): Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.common.images.ImageManager$b
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Parcel.readParcelable(Parcel.java:2077)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Parcel.readValue(Parcel.java:1965)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Parcel.readMapInternal(Parcel.java:2226)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Bundle.unparcel(Bundle.java:223)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.os.Bundle.getParcelable(Bundle.java:1165)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.content.Intent.getParcelableExtra(Intent.java:4489)
07-23 01:01:32.387: E/AndroidRuntime(615):  at com.google.android.gms.common.images.ImageBroadcastReceiver.onReceive(SourceFile:21)
07-23 01:01:32.387: E/AndroidRuntime(615):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2280)
07-23 01:01:32.387: E/AndroidRuntime(615):  ... 10 more

Inside my proguard-project.txt I have the following, but it still isnt good enough: 在我的proguard-project.txt中,我有以下内容,但仍然不够好:

-keep class com.google.android.gms.common.images.** { *; }
#Google Play service
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

Here is the project.properties file just in case: 这是project.properties文件,以防万一:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems. 
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available 

properties: sdk.dir, user.home):
proguard.config=${sdk.dir}\\tools\\proguard\\proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../android-sdk/extras/google/google_play_services/libproject/google-play-services_lib

Have you seen this ? 你见过这个吗 ?

https://developers.google.com/games/services/android/troubleshooting https://developers.google.com/games/services/android/troubleshooting

Proguard issues Proguard问题

If you are using Proguard and are seeing errors on the obfuscated APK, check the target API level on your AndroidManifest.xml. 如果您使用的是Proguard,并且在混淆的APK上看到错误,请在AndroidManifest.xml上检查目标API级别。 Make sure to set it to 17 or above. 确保将其设置为17或更高。

在您的proguard文件中添加-dontwarn com.google.android.gms.**

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM