googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.34k stars 1.09k forks source link

AppOpenAd Not Showing on Android 13 #3087

Closed Bricoda closed 5 months ago

Bricoda commented 6 months ago

After Loading "AppOpenAd" ads on the unity editor and after testing, the application can display ads, and it can convert from Foregrounded to Backgrounded. But after testing it on Android 13, it does not record any events after resuming the application. It is assumed that the advertisement will appear after moving to Foregrounded.

if (state == AppState.Foreground)
             {
                 ShowAd();
             }

But the application on Android is not able to log the AppState event.

"state" can be printed. In my case, I printed it as text, but it does not change or record any event.

text.text = ("App State changed to : " + state);

NVentimiglia commented 5 months ago

For AppOpenAds to work on Android please add the following dependencies:

[Android Only] Add lifecycle dependencies

Modify the GoogleMobileAdsDependencies.xml file to include and import the Android lifecycle dependencies.

<dependencies>
  <androidPackages>
    <androidPackage spec="androidx.lifecycle:lifecycle-common-java8:2.6.2">
      <repositories>
        <repository>https://maven.google.com/</repository>
      </repositories>
    </androidPackage>
    <androidPackage spec="androidx.lifecycle:lifecycle-process:2.6.2">
      <repositories>
        <repository>https://maven.google.com/</repository>
      </repositories>
    </androidPackage>
  </androidPackages>
</dependencies>
Bricoda commented 5 months ago

@NVentimiglia Thank you. The issue has been solved.