Can I specify the AdMob library in the build.gradle in Android Studio to avoid having the AdMob jar locally?
I've tried
dependencies {
compile 'com.google.ads:6.2.1+'
}
but it doesn't work. Am I missing something?
Better if you use following:
compile 'com.google.android.gms:play-services-ads:7.5.0'
Because, it will reduce your apk file size.
The latest version of Google Mobile Ads SDK for Android was released as part of Google Play services 4.0 (See Release Notes on Blog )
NOTE the following limitation:
The Google Mobile Ads APIs in Google Play services currently does not support DoubleClick For Publishers (DFP), Ad Exchange, or Search Ads for Mobile Apps.
So all you need in your gradle dependencies for Google AdMob:
dependencies {
// ... Other entries
compile 'com.google.android.gms:play-services:4.0.30'
}
The rest of the setup is explained here:
https://developers.google.com/mobile-ads-sdk/docs/
With my project it didn't work to load ads directly after adding the support as described on the docs. Instead it crashed initializing the layout.
What helped was one of the following things:
I dont think the google admob files are available on maven central. I think the only thing you can do is reference them locally
You need to include in you root build.gradle
allprojects {
repositories {
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
Then in your app/build.gradle you include
compile 'com.google.firebase:firebase-core:11.8.0'
in your dependencies block. You must also this line at the bottom of your app/build.gradle
apply plugin: 'com.google.gms.google-services'
在新版Android Studio中,它是这样的:
implementation 'com.google.android.gms:play-services-ads:11.8.0'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.