AdMob Android Messaging Platform (UMP) SDK app crash

1k views Asked by At

I have followed the guide from documentation and implemented the SDK in my app. I got the following crash report in Firebase.

Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'c.d.b.c.e.d.y c.d.b.c.e.d.w1.c' on a null object reference
   at com.google.android.gms.internal.consent_sdk.zzj.isConsentFormAvailable(zzj.java:13)
   at [my_app_package].MainActivity$1.onConsentInfoUpdateSuccess(MainActivity.java:1035)
   at com.google.android.gms.internal.consent_sdk.zzu.run(zzu.java:4)
   at android.os.Handler.handleCallback(Handler.java:938)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:239)
   at android.app.ActivityThread.main(ActivityThread.java:8142)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)

Anyone is getting the same problem?

The first line is obfuscated. I think the crash is because of the internal SDK issue. Anyone knows how to fix this?

FIX:

When I followed the guide as it is, I was getting memory leak. So, I passed getApplicationContext() to UserMessagingPlatform.getConsentInformation(). This is the reason why the app is getting crashed. Instead, I passed this (Activity context). Everything is fine now. To avoid memory leak, assign null to consentInformation and consentForm variables in the onDestroy() method. It worked for me.

1

There are 1 answers

3
brian_wang On

I encountered crash in calling isConsentFormAvailable() too:

java.lang.VerifyError: Verifier rejected class tl: void tl.a(tl) failed to verify: void tl.a(tl): [0x42] cannot access instance field v35 d35.b from object of type Reference: java.lang.Object (declaration of 'tl' appears in /data/app/HTTP://WEBADDRESS.ELIDED--jw7yUT1TEEM3YA7pQGONA==/HTTP://WEBADDRESS.ELIDED)

Turns out the following proguard rules are needed to fix the crash:

-keep class com.google.android.gms.internal.consent_sdk.** { <fields>; }
-keepattributes *Annotation*
-keepattributes Signature

Similar rules exist in old consent SDK.