Parcelable protocol requires a Parcelable.Creator object called CREATOR (I do have CREATOR)

后端 未结 6 633
天命终不由人
天命终不由人 2020-12-08 20:32

I am trying to pass Parcelable data from one intent to another and this is the error I am getting:

08-31 14:12:22.709: E/AndroidRuntime(9931): FATAL EXCEPTIO         


        
6条回答
  •  时光取名叫无心
    2020-12-08 20:51

    Just ran into this.

    I had a hunch, and I looked in my ProGuard mapping file.

    Normally I declare CREATOR like this:

        public static final Parcelable.Creator CREATOR = 
                new Parcelable.Creator() {
    

    which shows up in the mapping file like this:

        android.os.Parcelable$Creator CREATOR -> CREATOR
    

    ..except for one class, the class that was reported with the error. I declared it like this:

        public static Creator CREATOR =
                new Creator() {
    

    Lo and behold:

        android.os.Parcelable$Creator CREATOR -> a
    

    So if you are getting this exception in your production release, check your mapping file. I think ProGuard is really sensitive to how CREATOR is declared when deciding not to obfuscate it.

提交回复
热议问题