Adding ads to Android project

MarkedOneMarkedOne ARMember ✭✭

Hi, I'm following this guide by the one and only Mr. Montemagno and I'm having trouble with some parts of it.
I added permissions but when I try to integrate the AdView the guide says "Simply open the layout file where the ad will live". I only have Toolbar and Tabbar under Layouts and I'm not even using them, I set the 'layout' like this:

this.SetContentView(application.AndroidContentView);

What Layout does my program use? Do I need to create a layout and set it in SetContentView? All my game is working on Application.AndroidContentView so if I change it, it probably won't show it. (I know, too many questions, I'm kind of lost :D )

What I did was add the code in the guide to my Toolbar layout but the compiler says:

    ads:adSize="SMART_BANNER" // <- attribute not declared
    ads:adUnitId="@string/banner_ad_unit_id" /> // <- attribute not declared

Also on this line:
var adView = FindViewById<AdView>(Resource.Id.adView);
it says: 'Resource.Id' does not contain a definition of AdView even though it is set on the Toolbar layout like this:
android:id="@+id/adView"
Any ideas on what's going on?

Answers

  • KarhuKotiKarhuKoti USMember

    Having the same problem here. Seems to be quite a few articles on it on the internet, but can't quite get it correct here.
    Br, Karhu.

Sign In or Register to comment.