我在github示例中找到了解决方案,即:
代替
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
删除xmlns:ads ***标记并添加
xmlns:ads="http://schemas.android.com/apk/res-auto"
标记为LinearLayout标记,如下所示:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns: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"><TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello"/><com.google.android.gms.ads.AdView android: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>
而已 :)
这个xml的github链接



