Fixed: app crash after integrating Admob to Unity project

If your app crash after updating admob, see the final part.

First, check if you input the correct AdMob/Ad Manager Application ID. The correct one should be in the format: “ca-app-pub-################~##########”. 

A sample AdMob Application ID for testing is:

ca-app-pub-3940256099942544~3347511713

In order to see if test ads works during internal testing, for example, use that testing Application ID with the test unit IDs from Google

Edit the manifest:

Do the following,

  • In Player Settings >> Player >> Publishing Settings >> Build, enable “Custom Main Manifest”.
  • Go to Assets >> Plugins >> Android, open “AndroidManifest.xml”, add the following
            <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="YOUR_APP_ID" />

Here, “YOUR_APP_ID” is Your App ID, which looks something like “ca-app-pub-3940256099942544~3347511713”

If it still crash, in AndroidManifest, update the value of “package=”

If it still crash, add the following lines to AndroidManifest, after </application>

    <!-- Required permissions -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

If it still crash, try integrating via OpenUPM:

Instead of importing the Admob ads sdk by downloading the latest .unitypackage  from GitHub, follow the quick start guide from Google, but use the guide at the tab OpenUPM to import the Admob SDK instead, and follow the instruction.

If you imported from the .unitypackage before, and already removed everything related before following the OpenUPM integration instruction, you still need to delete the following after installing the  Google Mobile Ads for Unity package:

Assets/ExternalDependencyManager
Assets/GoogleMobileAds
Assets/Plugins/Android/googlemobileads-unity.aar
Assets/Plugins/Android/GoogleMobileAdsPlugin
Assets/Plugins/iOS/GADUAdNetworkExtras
Assets/Plugins/iOS/unity-plugin-library.a

Another nice thing about importing Admob via OpenUPM is that it is easy to remove it later on by simply go to Package manager >> Packages: In Projects >> select the admob package and then click the Remove button. Interestingly, removing it is much easier than integrating it ?

App crashes after updating Admob

After updating Admob, you need to recheck the deletion of file in the previous steps. This is because updating means re-importing these files, causing the crash. Also, check for the conflicts files, and delete files that cause the conflicts, if possible.


Discover more from Science Comics

Subscribe to get the latest posts sent to your email.

Leave a Reply

error: Content is protected !!