安卓BadParcelableException只有签署的apk [英] Android BadParcelableException only with signed apk

查看:212
本文介绍了安卓BadParcelableException只有签署的apk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行调试一切正常,我的项目。然而,当我跟我的机器人工作室(使用ProGuard的),我使用getParcelable时,得到如下错误产生的签署APK运行:

When I run my project from debug everything works fine. However when I run it with the signed apk I generated from Android Studio (using proguard), I get the following errors when using getParcelable:

java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage.android/mypackage.mobile.android.activities.searchActivity}: android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called  CREATOR on class mypackage.android.a.d.a

为什么会出现这种异常与我签订APK只发生?在我ProGuard的配置文件,我也必须使用 dontwarn android.support.v4。** 来避免ProGuard的错误。那是回来咬我?

Why does this exception happen only with my signed apk? In my proguard config file I did have to use dontwarn android.support.v4.** to avoid proguard errors. Is that coming back to bite me?

推荐答案

您需要保护 CREATOR 从ProGuard的的模糊领域

You need to protect CREATOR fields from proguard's obfuscation

添加此行到您的ProGuard配置:

add this lines to your proguard config:

-keep class * implements android.os.Parcelable { 
   public static final android.os.Parcelable$Creator *; 
}

这篇关于安卓BadParcelableException只有签署的apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆