在我的项目中添加AdMob?

时间:2015-01-05 14:06:59

标签: android admob

我正在尝试在我的项目中添加AdMob。问题是当我尝试构建项目时抛出关于AndroidManifest的minSdkVersion的异常。在我的AndroidManifest中,我将minSdkVersion设置为8,我尝试将minSdkVersion更改为9,但仍然无效。

我该如何解决?

异常

/home/fernando/workspace_2/app/src/main/AndroidManifest.xml
Error:(7, 5) uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library /home/fernando/workspace_2/app/build/intermediates/exploded-aar/com.google.android.gms/play-services/6.5.87/AndroidManifest.xml
Error:(7, 5) Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library /home/fernando/workspace_2/app/build/intermediates/exploded-aar/com.google.android.gms/play-services/6.5.87/AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="com.google.android.gms" to force usage

AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="br.com.package.myapp"
    android:versionCode="1"
    android:versionName="1.0" >

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

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


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <activity
            android:name=".act.SplashView"
            android:label="@string/app_name"
            android:configChanges="keyboardHidden|orientation"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".act.LoginView" />
        <activity android:name=".act.CadastrarView" />
        <activity android:name=".act.EsqueciSenha" />
        <activity android:name=".menu.CustomDrawerLayout"/>
        <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>

</manifest>

Gradle Depend

compile 'com.google.android.gms:play-services:6.+'

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。

我做了

defaultConfig {
        applicationId "br.com.package.myapp"
        minSdkVersion 9
        targetSdkVersion 21
    }