java – Exception: Unmarshalling unknown type code occurred at run time-ThrowExceptions

Exception or error:

I am working on Android app and we are working as a team. I am facing a serious issue. And that is when ever I try to get the data from intent it gives me following exception

Parcel android.os.Parcel@355932a: Unmarshalling unknown type code
4784211 at offset 712

I know on SO there are a lot of helping material related to this issue, but my case is different and quiet mind boggling …..

Here is a quick code to see how I am getting my object

       try {
                if (data.hasExtra("KEY_MY_MODEL")) { 

                    MyCustomModel newSelectedModel = data.getParcelableExtra("KEY_MY_MODEL");

                    //DO SOME THING WITH OBJECT
            } catch (Exception e) {

I am getting exception on first line if (data.hasExtra(“KEY_MY_MODEL”)) {

and this is quiet funny because when I inspect the intent object (data) while debugging and if I look into intent object using debugging I can see all my custom object.

The keys of getting object are same, if in any case the key is wrong I think the code inside the if condition must not get run. as it will return false.

But instead of returning false it is giving the above mentioned exception.

Case2: As I told you we are working in team, the same set of code is running perfectly on other system, but when I run app from my system and install app on device, it is giving the exception I mentioned above.

This is very much frustrating. I think there is something wrong with proguard, as I read on S.O but its still not helpful. Any Idea why this is happening? This looks like a big bug.

Note: I am using A.S 3.5 and on other system A.S 3.5 is in use, even we have same set of sdk, configurations and other things are quiet
identical on both sides…

How to solve:

It seems to be a ProGuard issue

Just add this line in

-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;

Leave a Reply

Your email address will not be published. Required fields are marked *