How to add ad in app?

Asked

Viewed 176 times

0

I’m using this code:

<com.google.android.gms.ads.AdView android:id="@+id/adView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  ads:adUnitId="MY_AD_UNIT_ID"
  ads:adSize="BANNER"/>

Initialization:

// Consultar o AdView como um recurso e carregar uma solicitação.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest); 

But you make a mistake:

Description Resource Path Location Type error: No Resource Identifier found for attribute 'loadAdOnCreate' in package 'com.teste.teste1' activity_teste.xml /Teste/res/layout line 120 Android AAPT Problem

this error I have already fixed, my code is the same as the one quoted in Graphical Layout where the BANNER is written in red

XML Required attribute " adSize " was Missing

  • Error says you have not set the attribute loadAdOnCreate in his AdView

  • and how I defined this attribute if you can help me

  • Could put the boot code?

  • @Wakim take a look at my issue

  • You declared the namespace ads somewhere?

  • I don’t understand your question

  • He meant if he declared: xmlns:ads="http://schemas.android.com/apk/res-auto" somewhere above the AdView.

Show 2 more comments

1 answer

0


Just remove the lines android:padding....... then it worked right.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.