AdMob in android "AdView missing XML attribute adSize"

I am trying to implement AdMob in my application. But I don’t know how to show this error, and because of this, the R.java file is not created. I tried all the ways to solve this problem, such as "Clean", "Build", "Build all." But not working for me. Following my snippet of code that displays its error "Error parsing XML: Unbound prefix"

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@color/bgcolor"> <LinearLayout android:id="@+id/Linearlayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" > <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="XXX" ads:refreshInterval="60"/> </LinearLayout> 

Please help me. I'm stuck here :(

+4
source share
3 answers

Probably a problem with the namespace. You must define a namespace.

try adding

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

+16
source

New Admob SDK (Google Play Services) requested a different namespace

 xmlns:ads="http://schemas.android.com/apk/res-auto" 
+6
source
 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:id="@+id/rltvLayoutPromote" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/linearLayoutwebview" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical"> <WebView android:id="@+id/webViewPromote" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fitsSystemWindows="true" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:id="@+id/ad_layout" android:layout_height="wrap_content" android:gravity="bottom" android:layout_alignParentBottom="true" android:layout_alignBottom="@+id/home_layout"> <com.google.ads.AdView android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="XXXXXXXXXX" ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" /> <!-- put 3 if not working--> </LinearLayout> </RelativeLayout> 

and put these lines in manifest.xml

  <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" /> 

the above code works fine for me ... visit this site for full help help forandroid-admob
Thanks Pragna

+3
source

Source: https://habr.com/ru/post/1368894/


All Articles