0
我正在实施横幅广告,但收到错误“必需的XML属性”adsize“缺失”。我用the developer.google.com link to add admob显示错误必填XML属性“adSize”丢失
我还访问了其他计算器的问题,如为Required XML attribute 'adsize' was missing (google play service)
和但错误是一样的我已经实现了一切。这是代码。
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.abhishek.canddatastructureprograms.MainActivity">
<FrameLayout
android:id="@+id/sample_content_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
MainActivity.java
在的onCreate加入下列代码()方法。
AdView mAdview= (AdView) findViewById(R.id.adView);
//AdRequest mAdRequest= new AdRequest().Builder.build();
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("9F099BD5E5700664591DEC5FDC92A40E") // An example device ID
.build();
mAdview.loadAd(request);
请让我知道如果我需要添加任何更多的细节或代码。
哇!非常感谢!!它现在有效。我甚至从未想过这会影响它。 –