Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android native ad admob

Tags:

android

admob

I have been trying to implement Native Ads from admob.

I got some sample code from Github. I tried to implement this code, and the demo code works fine. The native ads show up properly.

I then created my own Admob account and obtained an Ad Unit ID. The previous demo code for native ad did not work with this id, and I got an error with error code 0 although my created Ad Unit ID works fine for banner type ads.

Can someone help me out?

like image 493
aman attri Avatar asked Nov 10 '22 05:11

aman attri


1 Answers

guys i have facing same issue and finally i have a solution for it hope this will you all..:) enter image description here

Here in this image when you are trying to create an AdUnitId make sure that the width and height here will be same width and height in the XML file like this

 <com.google.android.gms.ads.NativeExpressAdView
  android:id="@+id/adView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
  android:layout_alignParentBottom="true"
  ads:adSize="360x320"
  ads:adUnitId="@string/NativeAdId">
</com.google.android.gms.ads.NativeExpressAdView>

One more thing you have to keep in mind that the width and height you are going to make ad will be fit in your xml layout ,So for this just first try It in your xml and then create an Native add for this.

Just try it and feel free to tell me if you will be facing any problem after doing this. Thank you

like image 106
Sudhansu Avatar answered Nov 14 '22 23:11

Sudhansu