sunnycupertino / cordova-plugin-admob-simple

Cordova plugin allowing Admob interstitials and banner ads.
MIT License
164 stars 150 forks source link

How to modify the AndroidManifest.xml if you are using build.phonegap.com #45

Open pragmaBit opened 5 years ago

pragmaBit commented 5 years ago

Hello everyone, after make an update of my app using build.phonegap.com I realized my app crash because my AndroidManifest doesn't has one of meta-data tag, so I searched for the way of add without having to use the apktool to decode, change and recode. So I found this doc in the cordova documentation https://cordova.apache.org/docs/en/8.x/plugin_ref/spec.html#edit-config

And I found this too in the page http://docs.phonegap.com/phonegap-build/configuring/config-file-element/

As of cli-7.0.1 on PhoneGap Build (and as long as you're using the new builder), modifying manifests is handled by Cordova with the edit-config element. Check out the cordova edit-config docs for usage details. Otherwise if you're using cli-6.5.0 and below (and/or the old builder), use the config-file element as documented below.

However, doesn't works because the documentation is inclomplete about the mode attribute, after made many changes and tests I was able to achive my app work using the follow code into the config.xml file

`

`

Of course also is needed to add xmlns:android="http://schemas.android.com/apk/res/android" into the widget tag.

I share this in case someone other can use it.

raf202 commented 5 years ago

could you please share? I'm having the crash problem too

pragmaBit commented 5 years ago

In your config.xml file change the widget tag to something like this

<widget id="[YOUR_APP_ID]" version="[YOUR_APP_VERSION]" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">

YOUR_APP_ID and YOUR_APP_VERSION must to be changed by your own data

And put the edit-config tag anyplace into the same config.xml file before your </widget> close tag

<edit-config file="AndroidManifest.xml" target="./application" mode="add"> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/> </edit-config>

Of course the ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX must to be changed by your own ADMOB APP ID

I hope this solve your problem too