Admob-plus-cordova

Hi Team,

I was building an admob integration mobile app. And I keep getting the following error on build.

UserError: This project uses AndroidX dependencies, but the ‘android.useAndroidX’ property is not enabled. Set this property to true in the gradle.properties file and retry.
You can fix this by adding this line to config.xml:

The thing is, when I add the entry it says I should set it to “false” and this is resolved in Cordova 11. - Any else have this issue? Is there a better Admob plugin I should use?

Can you share your entire build log with support@volt.build?

I still use <preference name="AndroidXEnabled" value="true"/>. Doesn’t seem to hurt.

I emailed my last build log. What build versions are you using? I see this when I enabled this variable, and target Cordova v9. If I target 10.1, I get a Gradle error I sent in the email.

Lastly, where do you specify the APPID? And what should the variable name be called? The log shows it in the package.json. (APP_ID_ANDROID) Admob Google Docs specify it should be in AndroidManifest.xml. (APPLICATION_ID)

Any help is appreciated… :slight_smile:

From what I gathered, when the plugin is installed, it should be included like this: Where the ID’s are pulled from the AndroidManifest.xml variables of the same name, instead of Google’s default name. (Hope this helps.)

cordova plugin add admob-plus-cordova --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx --variable APP_ID_IOS=ca-app-pub-xxx~xxx

Config.xml

< preference name=“AndroidXEnabled” value=“true” / >
< config-file parent=“/manifest/application” target=“AndroidManifest.xml” >
< meta-data android:name=“com.google.android.gms.ads.APP_ID_ANDROID” android:value=“ca-app-pub-xxx~xxx” / >
< meta-data android:name=“com.google.android.gms.ads.APP_ID_IOS” android:value=“ca-app-pub-xxx~xxx” />
< /config-file >

I also found this on StackOverflow:

A few things:

  1. Both cordova android engines 9 and 10 are very old at this point. We will be dropping support for 9 soon. 14 is just about to be released. I would suggest targeting 13 if possible.
  2. Here is the proper way to include variables in the config.xml: Config.xml API - Apache Cordova

Awesome! I missed that, when reading through the docs… I will give it a try.