Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to add Ads using Google Admobs in xamarin.android app?

I want to add Ads in my xamarin.android app using Google Admobs, Please help because I'm a newbie and thanks in advance

Tagged:

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited September 4

    To use the Google Admobs, we need to install the Xamarin.GooglePlayServices.Ads package. Then add the 'AdView' in the layout xml and set the adUnitId to display the ads.

    <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="@string/test_banner_ad_unit_id" />
    

    Tutorial:
    https://developers.google.com/admob/android/banner

    You could refer to the official sample code:
    https://docs.microsoft.com/en-us/samples/xamarin/monodroid-samples/google-services-admobexample/

  • CaptainPriceCaptainPrice Member ✭✭

    Hello Bro When i Download Xamarin.GooglePlayServices.Ads Packages Visual Studio Show Warning

    and when i install all warning packages also visual studio show warning to download Xamarin.Build.Download Package
    and when i install Xamarin.Build.Download Package and run my app visual studio show error and warning

Sign In or Register to comment.