Android 不运行Admob(帮助)错误(导入)的应用程序

Android 不运行Admob(帮助)错误(导入)的应用程序,android,admob,Android,Admob,请发送使用api 18(android4.2)或更高版本的测试admob MainActivity.java 与admob导入相关的导入文件不存在时出错 com.google.android.gms.ads.AdRequest;导入 com.google.android.gms.ads.AdView AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http:/

请发送使用api 18(android4.2)或更高版本的测试admob

MainActivity.java

与admob导入相关的导入文件不存在时出错 com.google.android.gms.ads.AdRequest;导入 com.google.android.gms.ads.AdView

AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />


    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.a.test.MainActivity"
            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.google.android.gms.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

    </application>

</manifest>

layout main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${packageName}.${activityClass}" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <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="MY ID"/>
</RelativeLayout>

希望您已经在项目中引用了google play services库。如果没有,请确保删除
/libs
/文件夹中的任何admob sdk jar,并在项目中引用google play services库版本4或更高版本。然后

在布局中,更改:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
致:

在您的清单中,添加:

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


确保您在
中添加了admob jarhow可以获取admobsdk
xmlns:ads="http://schemas.android.com/apk/res-auto"
<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />