4

I am getting following exception in production environment. It is related with parcelable classes. But it is not showing which class is problematic. Below is detailed log trace:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{in.app/in.app.activity.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@ae3c90f: Unmarshalling unknown type code -15962911 at offset 816
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
   at android.app.ActivityThread.-wrap11(Unknown Source)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
   at android.os.Handler.dispatchMessage(Handler.java:105)
   at android.os.Looper.loop(Looper.java:164)
   at android.app.ActivityThread.main(ActivityThread.java:6942)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

It is happening in onStart of Activity. I am not passing any parcelable object to the activity. It is launcher one. How can I find which parcelable is there at specifed
Unmarshalling unknown type code -15962911 at offset 816

Also as per Crashlytics, Device status is as follows:
100% Proximity on
3% App in background
It is happening on multiple OS versions.

MainActivity

public class MainActivity extends BaseActivity implements CleanUpDelegate,
    OnFilterAppliedListener,
    UpdatePhoneNoDialog.UpdatePhoneNoListener, GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener, GenericDialogOperationListener,
    DAPopupFragment.DAPopupOperationsListener,
    OnLoginListener, HomeScreenFragmentV2.showECOOrderPopup, BottomNavigationRVAdapter.BottomNavigationItemClick

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        createBottomNavigation();
    }

    @Override
    protected void onStart() {
        super.onStart();
        if (mGoogleApiClient != null) {
            mGoogleApiClient.connect();
        }
    }
}
Sagar Zala
  • 4,854
  • 9
  • 34
  • 62
Nitish
  • 3,097
  • 13
  • 45
  • 80
  • Since you got this in a production environment I'm almost sure it's related to ProGuard. Since you aren't using any self-made parcelable class it's most likely a library. What you could try is go through your library's GitHub page and see if you have included their ProGuard rules. – Zun Oct 25 '18 at 07:28
  • 1
    post your main activity code – Vivek Mishra Oct 25 '18 at 07:28
  • @VivekMishra Main Activity code added. Since class is very large so I added only relevant methods – Nitish Oct 25 '18 at 08:18
  • Are you writing anything in to a `Bundle` in `onSaveInstanceState()`? – azizbekian Nov 02 '18 at 10:55
  • post your model(Pojo class) its due to your Parcelable arrangement. – Atif AbbAsi Nov 04 '18 at 18:25

2 Answers2

1

Since it is happening in production, high probability is it is because of ProGuard obfuscating Parcelable classes.

Try including this in your ProGuard config file:

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

For further info, there is a recommended configuration for Android applications available in the ProGuard Manual, with detailed explanation about entries.

Ayush Khare
  • 1,802
  • 1
  • 15
  • 26
  • Is there any way find the unknown type code `unknown type code -15962911`. And this majorly happening on Oreo. – Nitish Oct 29 '18 at 05:23
  • Have a look [here](https://stackoverflow.com/questions/21342700/proguard-causing-runtimeexception-unmarshalling-unknown-type-code-in-parcelabl). I am not sure how to find the unknown type but this question might help you replicate the issue and get more info – Ayush Khare Nov 05 '18 at 02:45
0

The error:

Unmarshalling unknown type code XXXXX at offset XXXXX

Happens when you have an object that implements Parcelable that is malformed.

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

    @Override
    public MyClass createFromParcel(Parcel source){
        // The most common issues are in this constructor.
        return new MyClass(source);
    }

    @Override
    public MyClass[] newArray(int size){
        return new MyClass[size];
    }
}

When you Parcelable object needs to be recreated the return new MyClass(source); (using the above example) will be called. And this is where the most common issues happen:

  1. You have a variable on a certain type, and you are unmarshalling it as another type.

Example: you have a variable id that is from the type long and you are reading it like this id = source.readInt();

  1. You are trying to read a value that is not available in your Parcelable.

Example: You try to id = source.readInt(); but you forgot to dest.writeInt(id);

  1. Your Parcelable extends from another object that is also Parcelable and you forgot to call super in the read and write methods.

Example:

@Override
public void writeToParcel(Parcel dest, int flags) {
    // This is missing
    super.writeToParcel(dest, flags);
}
  1. Missing proguard rule:

This will preserve the special fields of all Parcelable implementations:

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

tl;dr This is pretty difficult to find what is the issue without all the source code. So my suggestion to you is that you check all your Parcelable objects that you are using in the activities you mention and check if they are well formed.

André Sousa
  • 1,692
  • 1
  • 12
  • 23