2017-11-18 53 views
0

我刚刚接触android.currently我正在使用eclipse与android 4.0 api 14.Before整合admob所有作品well.after整合admob后显示一个错误 “找不到属性adsize资源标识符”和“在main.xml中找不到属性adUnitId的资源标识符”在我的应用程序中集成Admob

我发现了许多类似的问题,但无法解决它。

我的main.xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/RootLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<LinearLayout 
     android:id="@+id/adLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:orientation="vertical" > 
    <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="@string/admob_publisher_id"/> 
     </LinearLayout> 
     </RelativeLayout> 

主要activity.java

import com.google.android.gms.ads.*; 

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

清单文件

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.easywebapp" 
android:installLocation="auto" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="18" /> 

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


<application 
    android:allowBackup="true" 
    android:hardwareAccelerated="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > 
    <meta-data android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version" /> 
    <activity 
     android:name="com.example.asd.Splashscreen" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

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

回答

0

代码似乎是谷歌fine.Check玩,如果包括验证其路径包括服务库。

0

尝试以下链接 refer here

<com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_home_footer"> 
    </com.google.android.gms.ads.AdView> 
0

在gradle这个文件中添加此

compile 'com.google.android.gms:play-services-ads:10.2.0' 
相关问题