Required Xml Attribute 'adsize' Was Missing (google Play Service)
There are so question like that but it's not duplicate because i have already used xmlns:ads='http://schemas.android.com/apk/res-auto' and i have done code mostly in java
Solution 1:
Change the namespace to
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
Ad.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><com.google.android.gms.ads.AdViewandroid:id="@+id/adview"android:layout_width="match_parent"android:layout_height="wrap_content"ads:adSize="BANNER" /></LinearLayout>
NOTE :
Use this Namespace for new SDK
xmlns:ads="http://schemas.android.com/apk/res-auto"
Solution 2:
Try add "ads:adSize" to XML like below:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adview"
ads:adSize="SMART_BANNER"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Solution 3:
Remove "adView.setAdSize(AdSize.SMART_BANNER);" from your java file.
Refer below:
Here is the XML layout
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:ads="http://schemas.android.com/apk/res-auto"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="@string/hello"/><com.google.android.gms.ads.AdViewandroid:id="@+id/adView"android:layout_width="match_parent"android:layout_height="wrap_content"ads:adSize="BANNER"ads:adUnitId="INSERT_YOUR_AD_UNIT_ID_HERE"/></LinearLayout>
And here is your java file
package com.google.example.gms.ads.xml;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import android.app.Activity;
import android.os.Bundle;
/**
* A simple {@link Activity} which embeds an AdView in its layout XML.
*/publicclassBannerXMLSampleextendsActivity {
privatestaticfinalStringTEST_DEVICE_ID="INSERT_YOUR_TEST_DEVICE_ID_HERE";
/** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// The "loadAdOnCreate" and "testDevices" XML attributes no longer available.AdViewadView= (AdView) this.findViewById(R.id.adView);
AdRequestadRequest=newAdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(TEST_DEVICE_ID)
.build();
adView.loadAd(adRequest);
}
}
Refer the example here https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob/banner-xml
Post a Comment for "Required Xml Attribute 'adsize' Was Missing (google Play Service)"