After enabling proguard null pointer exception

java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.lang.String.equals(java.lang.Object)’ on a null object reference

After debugging I have come to the conclusion that this is because that a value is not being passed from one activity to the other using putextra. This error only happens after enabling proguard. I am not aware of any keep rules to prevent this. Kindly suggest

1 Like

You could try using the -addconfigurationdebugging rule that was added in ProGuard 6.0.
I’m not sure it will help, but it should print some runtime suggestions that you can use and it has helped me in the past when I had weird issues. (make sure you disable it when you release your app)

Copied from the docs:

-addconfigurationdebugging
Specifies to instrument the processed code with debugging statements that print out suggestions for missing ProGuard configuration. This can be very useful to get practical hints at run-time , if your processed code crashes because it still lacks some configuration for reflection. For example, the code may be serializing classes with the GSON library and you may need some configuration for it. You can generally just copy/paste the suggestions from the console into your configuration file. Counter-indication: do not use this option in release versions, as it adds obfuscation information to the processed code.

1 Like

thanks for the suggestion. I tried it. Still stuck. Are you aware of anything that proguard does that prevents passing of values between activities through their intents and putextra. Because the root problem that the value is turning null because it is never getting passed from the previous activity

Would it be possible for you to share the full stack trace? The value you are talking about does it refer to a certain resource or class/method? If so, did you try creating a -keep rule for that value?

Hi @praveen_r_nair,

I know it’s been a while but since this seems like a bug, can you create an issue over on GitHub? If you can attach a reproducible sample that would be very helpful for us to resolve this.

Thank you for your time,
Jesse