尝试将admob添加到应用中。开始新项目并开始从以下方向开始:
https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start
已添加>编译'com.google.android.gms:play-services:6. +'<到gradle并同步,现在我无法运行,我得到这个错误:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices6587Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest
C:\Users\Emmi\Desktop\Android2015\adsplease\app\src\main\AndroidManifest.xml:0:0 Error:
uses-sdk:minSdkVersion 7 cannot be smaller than version 9 declared in library C:\Users\Emmi\Desktop\Android2015\adsplease\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
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 7 cannot be smaller than version 9 declared in library C:\Users\Emmi\Desktop\Android2015\adsplease\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
答案 0 :(得分:4)
如果您想将google_play_service
与SDK >= 8
和< 9
一起使用,则必须在清单中使用以下属性:
<uses-sdk
tools:overrideLibrary="com.google.android.gms.all,com.google.android.gms.ads,com.google.android.gms,
com.google.android.gms.analytics,com.google.android.gms.appindexing,
com.google.android.gms.appinvite,com.google.android.gms.appstate,com.google.android.gms.cast,com.google.android.gms.drive,
com.google.android.gms.fitness,com.google.android.gms.location,com.google.android.gms.maps,com.google.android.gms.games,
com.google.android.gms.gcm,com.google.android.gms.identity,com.google.android.gms.nearby,com.google.android.gms.panorama,
com.google.android.gms.plus,com.google.android.gms.safetynet,com.google.android.gms.wallet,com.google.android.gms.wearable"
/>
这解决了我的问题。
答案 1 :(得分:2)
uses-sdk:minSdkVersion 7不能小于声明的版本9 文库
你确定你的项目minSdk不是7,在AndroidManifest或gradle文件中吗?如果是这样,请将其增加到9。
答案 2 :(得分:0)
你必须将应用的最小sdk值增加到9,因为播放服务需要这个。这就是消息所说的内容。
您可以在应用程序gradle构建文件中执行此操作。
不要在应用程序的清单中执行此操作,因为gradle将使用gradle构建文件中的值覆盖它。
以下是apps modul build.gradle文件的简单最小示例:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example"
minSdkVersion 9
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.+'
}