ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
499 stars 214 forks source link

Changing APP_ID #365

Closed robertnicjoo closed 4 years ago

robertnicjoo commented 4 years ago

Hi, I've installed this plugin on Ionic 4 with my old app_id and then I got issue with admob that says I had duplicated account etc.

Anyway I've made new email and new admob account completely now I think I need to update my admob id which I added by installation code

cordova plugin add cordova-plugin-admob-free --save --variable ADMOB_APP_ID="<YOUR_ANDROID_ADMOB_APP_ID_AS_FOUND_IN_ADMOB>"

Question

Where can I find my old YOUR_ANDROID_ADMOB_APP_ID_AS_FOUND_IN_ADMOB in order to update it to my new account?

thanks.

robertnicjoo commented 4 years ago

Anyone?

tominou commented 4 years ago

It is in platforms/android/app/src/main/AndroidManifest.xml

This line <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-XXXXXXX~XXXXXXX" />

robertnicjoo commented 4 years ago

@tominou Ok, so I've changed value in file you mentioned also I've found it in package.json and changed it there as well but when I tried to build release version I got this error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
> Task :app:processReleaseManifest FAILED

So I've opened again AndroidManifest.xml file and i saw this:

//my edited line
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxx~xxxxxxxx" />

//added line after build command with OLD VALUE
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxxxx~xxxxxxxxxxxx" />

any idea where this old value comes from? it seems it's stored somewhere else and it's higher priority than my edited line so it keeps adding to AndroidManifest.xml file.

Thanks.

tominou commented 4 years ago

Check in platforms/android/app/src/. You should have a main folder, and if you have some others, check inside in they contain a AndroidManifest.xml file. If so, edit it to use the new APP_ID.

robertnicjoo commented 4 years ago

@tominou I checked every single file there nothing refer to my old app_id, except I found androind.json and fetch.json there I changed the value and run the command again. Same result happen (old error and added old value) so my best guess is i can fix it by reinstall the plugin.

Question

How do I remove this plugin in order to install it again?

tominou commented 4 years ago

cordova plugin rm --save cordova plugin add cordova-plugin-admob-free

robertnicjoo commented 4 years ago

something isn't right here, I tried to remove plugin by command it says Error: Variable(s) missing: ADMOB_APP_ID so i removed all files and folders by myself also removed dependencies from package.json etc. and reinstall it again. Yet it includes old value and new one both!!

tominou commented 4 years ago

Strange that it asks the variable when we want to remove it. Try this: cordova plugin rm cordova-plugin-admob-free --save --variable ADMOB_APP_ID="blabla" Then reinstall it.

Let me know if it finally works ^^

robertnicjoo commented 4 years ago

ok will try this but the problem is that <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" is duplicated that's why my app can't be build and i don't get it why this old value keeps adding to my manifest file!

tominou commented 4 years ago

Okay so try this command from the root of your project (if you are on linux): grep -rnw '.' -e 'com.google.android.gms.ads.APPLICATION_ID'

Then change the APP_ID manually in all those files.

robertnicjoo commented 4 years ago

OK I solved my issue this way:

  1. removed this plugin
  2. removed ionic native admob-free
  3. removed android platform
  4. add android platform
  5. add this plugin
  6. add ionic native admob-free

this does clean whatever cache was to add my old value.

hope it help others.