android - Android Studio Admob 错误属性未知
问题描述
我在放置广告横幅时遇到错误,如下面 的错误在这里
抱歉,它说您需要 10 或更多声望才能发布图片。
我的广告 XML 代码如下
<com.google.android.gms.ads.AdView
android:id="@+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
据说我必须把代码:
ads:adSize
放在那里,但每次我放ads:adSize
它都会变成红色并变成错误:属性未知。
我错过了安装中的一些东西吗?
我该怎么做才能不会发生错误?
解决方案
你需要一个属性ads:adSize="BANNER"
您可以使用以下代码添加代码:
final AdView adView = new AdView(getActivity());
adView.setAdUnitId("YourId");
adView.setAdSize(AdSize.BANNER);
推荐阅读
- dgraph - Dgraph:在控制台中看不到 API 数据
- javascript - 在 useEffect 中定义时,突出显示 div 的变量未正确设置
- java - 我怎么知道是什么导致了我的实体类 getTeamId 中的空指针
- excel - 删除 BG 列中没有信息的所有行
- python - sqlite3 和 python :sqlite3.OperationalError:
- python-3.x - 如何将sql查询转换为列表?
- flutter - 在警报对话框中保存多选选择芯片选择/未选择状态
- javascript - Chrome/V8 如何处理 javascript 中的大对象?
- php - 点击事件上的jquery只触发一次
- vgg-net - 使用 vgg16 提取特征来训练 LSTM