1

We sometimes throw new exception without specifying exception message. For example:

throw new NullPointerException();

However, because of the above code, sometimes NullPointerException like below happens:

Exception: java.lang.NullPointerException: println needs a message at android.os.Parcel.readException(Parcel.java:1605)

I think I could solve this problem by adding message like below:

throw new NullPointerException("blah");

However, what if I cannot find where the problem code is, and there are too many 'throw new NullPointerException();' so that I don't want to mess-up our company's project by adding exception message at all of the Exception codes.

I cannot modify Parcel.java because it is AOSP code. Can I get some ideas? Should I track where in the source code uses Parcel.java?

The real crash exception I got is here:

java.lang.NullPointerException: println needs a message
    at android.os.Parcel.readException(Parcel.java:1605)
    at android.os.Parcel.readException(Parcel.java:1552)
    at com.google.android.gms.internal.zzee.zzb(Unknown Source)
    at com.google.android.gms.internal.zzdzm.zzd(Unknown Source)
    at com.google.android.gms.internal.zzdzr.zza(Unknown Source)
    at com.google.android.gms.common.api.internal.zzm.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzc.zza(Unknown Source)
    at com.google.android.gms.common.api.internal.zzbr.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzbr.zzakz(Unknown Source)
    at com.google.android.gms.common.api.internal.zzbr.onConnected(Unknown Source)
    at com.google.android.gms.common.internal.zzac.onConnected$51662RJ4E9NMIP1FDTPIUGJLDPI6OP9R55B0____0(Unknown Source)
    at com.google.android.gms.common.internal.zzn.zzamz(Unknown Source)
    at com.google.android.gms.common.internal.zze.zzy(Unknown Source)
    at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.os.HandlerThread.run(HandlerThread.java:61)
John
  • 1,139
  • 3
  • 16
  • 33
  • Possible duplicate of [NullPointerException : println needs a message in android](https://stackoverflow.com/questions/6018633/nullpointerexception-println-needs-a-message-in-android) – AskNilesh Apr 24 '18 at 07:13
  • can you provide some more line of code. I think you are printing something from pojo class which implements parcelable interface. so I think the problem occured because of object of pojo not because of ArrayIndexOutOfBoundException() – Ritesh Apr 24 '18 at 07:14
  • @NileshRathod yes it is quite same, but what I need is different. – John Apr 24 '18 at 07:25
  • @Ritesh The problem is I cannot find where in the source code the problem happened. I attached whole exception message. – John Apr 24 '18 at 07:26

0 Answers0