NullPointerException
NullPointerException

Reputation: 37701

Deobfuscating file doesn't work with this exception

I uploaded the deobfuscate file to the console but... deobfuscate files seems to work incorrectly with this exception. I'm obfuscating the code with the new R8 system instead proguard because I'm using the last android studio, but this happened also before with proguard. I can see a lot of exceptions in my google play developer console with this text:

java.lang.NullPointerException: 
  at com.myapp.Util.capitalize (Util.java)
  or                     .clearRAM (Util.java)
  or                     .firstCharToUpperCase (Util.java)
  or                     .formatSize (Util.java)
  or                     .getBenchmarkResultsMap (Util.java)
  or                     .getColorFromStyle (Util.java)
  or                     .getLocaleStringResource (Util.java)
  or                     .getStringList (Util.java)
  or                     .goToAppSettingsDialog (Util.java)
  or                     .persistInt (Util.java)
  or                     .persistString (Util.java)
  or                     .persistStringArrayList (Util.java)
  or                     .sendEmail (Util.java)
  or                     .share (Util.java)
  at com.myapp.SystemInfoHelper.getExternalSdCardTotalSize (SystemInfoHelper.java)
  or                     .getFormattedExternalSdCardSize (SystemInfoHelper.java)
  at com.myapp.SystemInfoStringBuilder.getSystemSummaryList (SystemInfoStringBuilder.java)
  at com.myapp.activities.MainActivity$5$1.run (MainActivity.java)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:145)
  at android.app.ActivityThread.main (ActivityThread.java:6134)
  at java.lang.reflect.Method.invoke (Method.java)
  at java.lang.reflect.Method.invoke (Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1399)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)
  at de.robv.android.xposed.XposedBridge.main (XposedBridge.java:95)

As you can see, it didn't tell in which line or function is the problem, instead of it, it tell "at, or, at, or" and not clarifies where is the crash.

How can I solve this problem?

Upvotes: 1

Views: 157

Answers (1)

Matt Insko
Matt Insko

Reputation: 259

When line numbers are removed from the meta data, the stacktraces will not include them which can make it a bit more difficult to see where the issue occurred. You can add --keepattributes LineNumberTable to your R8 configuration to preserve these.

Unfortunately, that will not help your current situation. In this case I would recommend starting with:

com.myapp.SystemInfoStringBuilder.getSystemSummaryList

and determine if that calls:

com.myapp.SystemInfoHelper.getExternalSdCardTotalSize

or

com.myapp.SystemInfoHelper.getFormattedExternalSdCardSize

If it calls both (based on the names it probably does), the next step gets a bit more burdensome.

From that method determine which of the com.myapp.Util's methods are called. Note that you may also be able to eliminate some of the long list of com.myapp.Util's methods by investigating the code to determine if they would actually throw a NullPointerException.

The last option would be to code in Kotlin because it will enforce you to explicitly allow nulls on a given variable or parameter.

Upvotes: 1

Related Questions