【问题标题】:No resource identifier found for attribute adSize in package在包中找不到属性 adSize 的资源标识符
【发布时间】:2015-05-01 20:35:45
【问题描述】:

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

在我的清单中:

<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 活动布局中:

<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>

我在主要活动中的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);

很遗憾,这不起作用,我收到此错误

错误:在包中找不到属性“adSize”的资源标识符

【问题讨论】:

    标签: android admob


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-05-26
      • 1970-01-01
      • 2015-05-03
      • 2015-12-26
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多