Search code examples
c#androidunity-game-engineadmob

java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider


I'm developing a mobile game in Unity. I installed Admob to add ads to my game and wrote the necessary code. I used the test IDs provided by Admob in the ID sections. The game runs smoothly in the Unity Editor. However, when I transferred it to my phone, test ads were not showing. Now, when I try to run the game, I can't even open it. It gives me the following error summary:

Text:

java.lang.RuntimeException: Unable to get provider
 com.google.android.gms.ads.MobileAdsInitProvider: 
java.lang.IllegalStateException:
 * Invalid application ID. Follow instructions here:
 *
 * https://googlemobileadssdk.page.link/admob -android-update-manifest 
 * to find your app ID.
 *
 * Google Ad Manager publishers should follow instructions here:
 * https://googlemobileadssdk.page.link/ad-manager -android-update-manifest.

 at android.app.ActivityThread.installProvider(ActivityThread.java:7194)
 at android.app.ActivityThread.installContentProviders(ActivityThread.java:6672)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6567)
 at android.app.ActivityThread.access$1400(ActivityThread.java:224)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
 at android.os.Handler.dispatchMessage(Handler.java:107)
 at android.os.Looper.loop(Looper.java:224)
 at android.app.ActivityThread.main(ActivityThread.java:7562)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.IllegalStateException:
 *******************************
 * Invalid application ID. Follow instructions here:
 *
 * https://googlemobileadssdk.page.link/admob -android-update-manifest
 * to find your app ID.
 *
 * Google Ad Manager publishers should follow instructions here:
 * https://googlemobileadssdk.page.link/ad-manager -android-update-manifest.
 *
 ******************

 at p0.e3.attachInfo(Unknown Source:99)
 at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(Unknown Source:2)
 at android.app.ActivityThread.installProvider(ActivityThread.java:7189)
 ... 10 more

What is the solution to this error?

Test ads appear in the Unity Editor but not on my Android device. While trying to solve this, I can no longer even open the game.


Solution

  • in error message it says "Invalid application ID."

    a) Are you add the app Id to your unity project ? if you haven't done this, you shuld copy the app id from admob and add to your unity project. and here is the steps for this:

    1. go to admob and choose your current project.
    2. go to Application settings and in this tab you will find the Application ID. Copy this id.
    3. Open your unity project. And go to Assets -> Google Mobile Ads -> Settings tab. In this tab you will find "Google Mobile Ads App Id". Paste the app id which you copied in step 2.
    4. Now build your project again and check for result.

    b) Maybe the app id that you add the project is wrong App Id. check for it.