gpt4 book ai didi

android - Admob:无法初始化 AdView:缺少必需的 XML 属性 "adSize"

转载 作者:行者123 更新时间:2023-11-30 03:12:42 24 4
gpt4 key购买 nike

按照官方链接中的步骤操作,也找不到问题出在哪里。我已经从以下位置下载了库:https://developers.google.com/mobile-ads-sdk/download#downloadandroid这是我的代码:在 MainActivity 中我添加:

adView = (AdView) findViewById(R.id.ad);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);

在 list 中:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

还有 xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/lytMain"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/libs/com.google.ads"
android:layout_width="fill_parent" android:layout_height="fill_parent">

<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-xxxxxxxx/xxxxxx"
ads:testDevices="TEST_EMULATOR"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
>
<TextView
android:id="@+id/cargando"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cargando resultados..."
android:textColor="@android:color/black"
android:textSize="20sp" />


<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Small.Inverse"
android:layout_marginRight="5dp" />

<Button
android:id="@+id/button"
android:visibility="invisible"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Ver resultados" />


</LinearLayout>
</LinearLayout>

最佳答案

在最新的 SDK 中:

XML:

<com.google.android.gms.ads.AdView 
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxxxxxxxxxxx" />

代码:

adView = (AdView) findViewById(R.id.adView);    
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);

关于android - Admob:无法初始化 AdView:缺少必需的 XML 属性 "adSize",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20679735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com