Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android BadParcelableException(Parcelable protocol requires a Parcelable.Creator object called CREATOR) only with signed 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

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?

like image 556
Adam Johns Avatar asked Oct 09 '13 14:10

Adam Johns


1 Answers

You need to protect CREATOR fields from proguard's obfuscation

add this lines to your proguard config:

-keep class * implements android.os.Parcelable { 
   public static final android.os.Parcelable$Creator *; 
}
like image 89
Selvin Avatar answered Sep 27 '22 17:09

Selvin