question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullReferenceException UMP

See original GitHub issue

Step 1: Describe your environment

  • Unity version: 2021.3.13f1 2021.3.18f1
  • Google Mobile Ads Unity plugin version: 7.4.0 7.4.1
  • Platform: Android and iOS
  • Platform OS version: All
  • Any specific devices issue occurs on: All
  • Mediation ad networks used, and their versions: None

Step 2: Describe the problem

No UMP message appears when the app starts, says:

NullReferenceException: Object reference not set to an instance of an object.   
at GoogleMobileAds.Ump.Android.Utils.GetConsentRequestParametersJavaObject (GoogleMobileAds.Ump.Api.ConsentRequestParameters consentRequestParameters, UnityEngine.AndroidJavaObject activity) [0x00000] in <00000000000000000000000000000000>:0 
at GoogleMobileAds.Ump.Android.ConsentInformationClient.Update (GoogleMobileAds.Ump.Api.ConsentRequestParameters request, System.Action onConsentInfoUpdateSuccessCallback, System.Action1[T] onConsentInfoUpdateFailureCallback) [0x00000] in <00000000000000000000000000000000>:0 
at GoogleMobileAds.Ump.Api.ConsentInformation.Update (GoogleMobileAds.Ump.Api.ConsentRequestParameters request, System.Action1[T] consentInfoUpdateCallback) [0x00000] in <00000000000000000000000000000000>:0 

But when you add a debug option (even if it is null) it appears correctly. On iOS never appears, a null message error also appears. I am currently testing it within the EU

Steps to reproduce:

Start the app normally

Relevant Code:

using System.Collections;
using System.Collections.Generic;
using GoogleMobileAds.Ump.Api;
using UnityEngine;

public class UMP : MonoBehaviour
{
    private ConsentForm consentForm;

    void Start()
    {
        UpdateConsentInformation();
    }

    public void UpdateConsentInformation()
    {
        var tagForUnderAgeOfConsent = false;
        var consentRequestParameters = new ConsentRequestParameters();
        consentRequestParameters.TagForUnderAgeOfConsent = tagForUnderAgeOfConsent;
        ConsentInformation.Update(consentRequestParameters,
            (FormError error) =>
            {
                if (error == null)
                {
                    if (ConsentInformation.ConsentStatus == ConsentStatus.Required) { LoadConsentForm(); }
                }
                else
                {

                }

            });
    }

    public void LoadConsentForm()
    {
        ConsentForm.Load(
                (ConsentForm form, FormError error) =>
                {
                    if (form != null)
                    {
                        consentForm = form;
                        ShowConsentForm();
                    }
                    else
                    {

                    }
                });
    }

    public void ShowConsentForm()
    {
        consentForm.Show(
                 (FormError error) =>
                 {
                     if (error == null)
                     {

                     }
                     else
                     {

                     }
                 });
    }

}

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gollobocommented, Mar 30, 2023

Hi @NVentimiglia ! This error still exist in the new release

NullReferenceException: Object reference not set to an instance of an object. at GoogleMobileAds.Ump.Android.Utils.GetConsentRequestParametersJavaObject (GoogleMobileAds.Ump.Api.ConsentRequestParameters consentRequestParameters, UnityEngine.AndroidJavaObject activity) at GoogleMobileAds.Ump.Android.ConsentInformationClient.Update (GoogleMobileAds.Ump.Api.ConsentRequestParameters request, System.Action onConsentInfoUpdateSuccessCallback, System.Action`1[T] onConsentInfoUpdateFailureCallback) at GoogleMobileAds.Ump.Api.ConsentInformation.Update (GoogleMobileAds.Ump.Api.ConsentRequestParameters request, System.Action`1[T] consentInfoUpdateCallback)

1reaction
NVentimigliacommented, Feb 28, 2023

Hi @YanoTikkk and @j111194

We are working on the fix, and scheduling it for the next release. We understand this is important, and thank you for your patience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Null Reference Exception in Unity - YouTube
If it is null then you will want to do nothing but if it returns a proper ... 3D Tutorial for Beginners (Simple...
Read more >
How to CHECK IF AN OBJECT EXISTS in Unity to ... - YouTube
A NullReferenceException error in Unity will not crash the game or ... Character Controller With Animations - Walk, Run, Jump & Attack ...
Read more >
NullReferenceException when making build[SOLVED]
So I'm updating an old 5.5.2 project to 5.6.5p1 and I've updated PlayMaker to the latest version. It runs fine in the editor,...
Read more >
Null Reference Exception - Forums
So I'm making a game for my college course and I have a problem where when I start up the game in editor...
Read more >
GoogleMobile Ads UMP
I have a problem with the google ump sdk, when calling the ... it generates an error ( NullReferenceException: Object reference not set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found