gpt4 book ai didi

android - 在包中找不到属性 adSize 的资源标识符

转载 作者:行者123 更新时间:2023-11-29 01:33:27 25 4
gpt4 key购买 nike

我正在尝试在我的应用程序中添加 AdMob 广告。

在我的 list 中:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />

在我使用的 xml Activity 布局中:

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

我在主要 Activity 中的 java 代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

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

不幸的是,这不起作用,我收到了这个错误

error: No resource identifier found for attribute 'adSize' in package

最佳答案

遇到此问题的其他人通过在自定义布局命名空间中将 /res 替换为 /lib 来解决。

xmlns:android="http://schemas.android.com/apk/res/android" will be

xmlns:yourApp="http://schemas.android.com/apk/lib/com.yourApppackage.yourClass"

关于android - 在包中找不到属性 adSize 的资源标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29994738/

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