简体   繁体   中英

Can't get Admob working in my Cordova Android app in VS2017

I've been going round in circles here, trying to get the Admob Pro plugin to work. I get endless build errors. If anyone has recently got Admob ads working in their Cordova project (using any plugin) I'd be grateful for the exact steps I need to follow to do that. I don't mind which plugin. I say recently because I imagine a lot depends on the particular version numbers all working with each other. I've been using:

  • VS Community 2017
  • Cordova 6.3.1
  • cordova-android 5.2.1
  • Android target API level 28
  • AdMob Plugin Pro 2.49.0
  • PLAY_SERVICES_VERSION 18.2.0
  • Google Mobile Ads SDK for Cordova 7.49.0

Many thanks

To target api 28 you'll need cordova-Android 8 or later and cordova as well. I was using vs community 2015 but decided to use this as an opportunity to migrate to using VsCode which I find a much less opaque since everything is done from the command line. I had to upgrade Cordova to 8.1.1. You also need to be aware of GDPR consent, and of the upcoming CCPA changes. I use the following plugins:

https://github.com/Longs/cordova-plugin-ad-admob.git NB I haven't uploaded the additional functionality to pass in GDPR consent yet and this is Android only in any case.

https://github.com/dragonbane0/cordova-plugin-google-consent.git NB this is incompatible with Cordova 9 so I use it with Cordova 8.1

"cordova-plugin-extras-google-play-services": "^1.0.5"

"cordova-plugin-ad-admob-sdk": "^1.0.1"

From memory I believe that one or more of the plugins generated an issue with the new AndroidX versions so I needed to add:

"cordova-plugin-androidx": "^1.0.2", "cordova-plugin-androidx-adapter": "^1.1.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM