Fatal Exception: java.lang.NullPointerException in release build

Disabling R8 entirely might not be a good idea. But by adding below lines in your Proguard Rules file might solve the issue --

-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
  }
-keep,allowobfuscation @interface com.google.gson.annotations.SerializedName

This is also suggested by one of the Google developers as the desired solution. You can find his answer here and you can also follow the entire discussion around it.


Finally solved this issue. This is because of the new R8 code obfuscation. Simply disable it from your project by adding this to the gradle.properties file

android.enableR8=false

Additionally you add this to your proguard rules file.

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}

However adding this to the proguard didn't really worked out.