[Solved] Google Play Services + Admob Issues

I’m having major problems trying to integrate google play services and admob.

I’m using the latest google play service plugin (0.0.94) from here and VNITS’s admob plugin.

The problem is that the game keeps crashing when I try to add the neccessay admob dependencies to the manifest.

<!-- Admob Dependencies -->

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>

<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

If I add the admob dependencies as shown above, the ads work but when I press the “sign in” button, the app crashes, bringing up the annoying message “Unfortunately, your app has stopped.”

If I remove the admob plugin and erase the admob dependencies from the manifest then the game doesn’t crash when I press the “sign in” button but if i remove the admob plugin and leave the admob dependencies in the manifest, the game still crashes.

I might be wrong but maybe the admob dependencies in the manifest are somehow clashing with the google play services. I tried this solution but got the exact same result.

I’ve been trying to work around this for hours but I just can’t seem to get admob to work with google play services without the game crashing.

Any help would be great.

Thanks.

Ok, I’ve finally managed to solve it. Both Google play services and admob are working perfectly without any crashes occurring :slight_smile:

For any one going through the same issue, the fix is EXTREMELY simple. Just add the following to your manifest :

<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ AppID"/>
<meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ AppID"/>

Replace “AppID” with your numerical application ID.

2 Likes

The manifest file is generated by Unity, so how you edit it? do you extract the manifest file from the APK or somethign like that?

After making an android build, you’ll find the generated manifest file in the StagingArea folder. You can navigate there by going to your projects root folder and clicking on the Temp folder.

Just drag & drop the “AndroidManifest.xml” to “Plugins/Android” in your assets folder and you should be able to edit it. Now when you make another build, it will use that manifest rather than generating a new one.

what is the numerical application ID ?

how to get it ?

You get it from your Google Play Developer Console when you set up Game Services for your app.

The problem is that the game keeps crashing when I try to add the neccessay admob dependencies to the manifest.
I have add two line in manifest file .

  • <meta-data android:name=“com.google.android.gms.games.APP_ID” android:value=“\ AppID”/>
  • <meta-data android:name=“com.google.android.gms.appstate.APP_ID” android:value=“\ AppID”/>

after still generate same problem of crashing unity. Please help me. Thank you.

Have you added the following to your manifest?

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>

<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

admob not need this meta
you can read this document https://github.com/unity-plugins/Unity-Admob

T

Thanks

Thanks. This works.