0

I am trying to implement AdMob in my Xamarin Form app. I am following AdMob In Xamarin Forms to implement AdMob ad. However, it seems the ad is not appearing. In the output I am getting following output which shows something is not working.

I added following two packages in my Android project.

Xamarin.GooglePlayServices.Ad

Xamarin.Firebase.Ads

02-29 23:23:58.145 W/mpanyname.dest( 5974): JNI RegisterNativeMethods: attempt to register 0 native methods for crc64b6d8dc29f1e2b389.AdMobViewRenderer 
02-29 23:23:58.216 D/DynamitePackage( 5974): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl 
02-29 23:23:58.232 I/Ads     ( 5974): This request is sent from a test device. 
02-29 23:23:58.294 I/mpanyname.dest( 5974): The ClassLoaderContext is a special shared library. 
02-29 23:23:58.366 I/DynamiteModule( 5974): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21200 
02-29 23:23:58.366 I/DynamiteModule( 5974): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21200 
02-29 23:23:58.545 I/mpanyname.dest( 5974): Background concurrent copying GC freed 8964(1124KB) AllocSpace objects, 7(356KB) LOS objects, 49% free, 3MB/7MB, paused 1.763ms total 203.190ms 
02-29 23:23:58.765 E/FA      ( 5974): GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.

I don't know why it is not showing, but I guess according to the output there could be some error.

Output After removing Xamarin.Firebase.Ads because I only want Google play services ad.

03-03 14:27:45.967 D/DynamitePackage(16402): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
03-03 14:27:45.985 I/Ads     (16402): This request is sent from a test device.
03-03 14:27:46.227 I/DynamiteModule(16402): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21200
03-03 14:27:46.228 I/DynamiteModule(16402): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21200
03-03 14:27:46.263 I/mpanyname.dest(16402): The ClassLoaderContext is a special shared library.
03-03 14:27:46.354 W/Ads     (16402): Invoke Firebase method getInstance error.
03-03 14:27:46.355 W/Ads     (16402): The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date
03-03 14:27:46.738 W/mpanyname.dest(16402): Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
6
  • this is a pretty specific message: "Missing google app id value from from string resources with name google_app_id."
    – Jason
    Mar 1, 2020 at 0:01
  • but I have added app Id is the androidmanifest <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-number~number" /> and also added in MainActivity in Android project. Where I have to look for google app Id?
    – ARH
    Mar 1, 2020 at 0:18
  • Did you initialize the ads Library?
    – Jason
    Mar 1, 2020 at 1:02
  • I have added this line in MainActivity before LoadApp. MobileAds.Initialize(ApplicationContext, "ca-app-pub-number~number");
    – ARH
    Mar 1, 2020 at 1:08
  • did you add it before Forms.Init?
    – Jason
    Mar 1, 2020 at 1:09

2 Answers 2

1

Solved my issue by these steps.

  1. Removed Xamarin.GooglePlayServices.Ad and Xamarin.Firebase.Ads packages
  2. Added the lite version of Xamarin.GooglePlayServices.Ads.Lite
  3. Added test Unit Id found in Admob Test Ads
  4. Added true for Application ID in Adnroid manifest instead of Application Id

Edit 5. You need to make sure that you have created your account in admob and it is approved. That means that you have to add your account details and bank information (not payment method) then you receive an approval email from admob that your ad can appear and they also send you a guide on how to incorporate your ads which exactly the steps mentioned in my answer.

3
  • Not sure what you mean by #4. I used this and it failed using... ` <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="true" />` Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException With the Application ID in there, I was able to get the sample adunit to show, however, when i use a real adunit it does not show. get ad failed to load message in my output. I created the adunit months ago, and created a new one tonight too, same results. Ideas? I am supposed to register my device for ad testing? May 14, 2020 at 4:34
  • You need to make sure that your account is activiated in admob website. When you receive account activation email from admob, then every thing works as expected.
    – ARH
    May 16, 2020 at 2:17
  • I haven't paying attention to the fact that I have to add payment info! Thank you for spotting that little detail.
    – Or Assraf
    Jul 16, 2020 at 0:27
0

Since you are using firebase, you will need to register your app with Firebase as under:

https://firebase.google.com/docs/android/setup

After registration download "google-services.json" file and add it to your android applications root directory. Then right click on google-services.json and set the build order to this file. Build your solution and test.

3
  • Is it important to add Xamarin.Firebase.Ads for AdMob? I want to use Xamarin.GooglePlayServices.Ad only. I am not interested to use Firebase, but I thought it may work with adding firebase because initally it was not working with only adding googleplayservices.
    – ARH
    Mar 3, 2020 at 13:54
  • AdMob will work with Xamarin.GooglePlayServices.Ad. Just make sure any dependent packages are also installed. It's not necessary to add Firebase unless you are using other services like Firebase analytics etc.
    – CloudArch
    Mar 4, 2020 at 8:38
  • I have added GooglePlayServices.Ad, but still no success.
    – ARH
    Mar 8, 2020 at 19:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.