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

Customize Google Play Services versions (Android only) Not Working #229

Open fontventa opened 5 years ago

fontventa commented 5 years ago

Hi, I'm trying to customize my Google Play Services version but it is not working. I started a new project with your plugin only. Here is my config.xml:

`

`

And this is my project.properties:

target=android-26 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4 cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4

What am I doing wrong?

Regards

paulstelzer commented 5 years ago

you have to reinstall it or just look at package.json - plugins/android.json - plugins/fetch.json if the new play services version was correctly set.

PS: I also change it in plugins/cordova-admob-sdk/plugin.xml in line 16.

The platforms/android folder should be empty before you add the android platform again

fontventa commented 5 years ago

Hi @paulstelzer

Yes, I changed it in plugins/cordova-admob-sdk/plugin.xml and works, but I think it is not the right way to solve it. I expected a clean solution without changing code in plugins folder.

paulstelzer commented 5 years ago

@fontventa I think you added the variable to your config.xml afterwards, isn't it? In this case the 11.0.4 version is put in at package.json - plugins/android.json - plugins/fetch.json - (or if you not set any version, no version will be set and then he takes 11.0.4 as standard) etc, so cordova take the variable from their and not your config.xml. That's the reason you have to remove the plugin completely before adding it again, then it would work without modifying the plugin.xml

fontventa commented 5 years ago

@paulstelzer Yes, in my config.xml I've setted PLAY_SERVICES_VERSION like this:

`

<plugin name="cordova-plugin-admob-free" spec="^0.17.0" />

`

packages.json is setted like this:

"cordova-admob-sdk": { "PLAY_SERVICES_VERSION": "15.+" }, "cordova-plugin-admob-free": {}

After I checked that, I add android platform and fetch.json is setted with:

"cordova-admob-sdk": { "source": { "type": "registry", "id": "cordova-admob-sdk@~0.17.0" }, "is_top_level": false, "variables": {} }, "cordova-plugin-admob-free": { "source": { "type": "registry", "id": "cordova-plugin-admob-free" }, "is_top_level": true, "variables": {} }

And android.json is setted like this:

"cordova-admob-sdk": { "PLAY_SERVICES_VERSION": "11.0.4", "PACKAGE_NAME": "org.misas.Misas.org" }, As you can see, it doesn't set my PLAY_SERVICES_VERSION automatically. May I change it by myself in fetch.json and android.json?

fontventa commented 5 years ago

I solved it uninstalling the plugin, then I added cordova-admob-sdk, then I added cordova-plugin-admob-free.

Lenndev commented 5 years ago

@fontventa but cordova-admob-sdk is being installed as a dependency of cordova-plugin-admob-free... i don't think installing them manually is the way to go... (i don't blame you though). @ratson isn't there a way to set the variable PLAY_SERVICES_VERSION for the dependency? imo it looks like the problem lies within that plugin. it does check for the variable PLAY_SERVICES_VERSION but default version is 11.0.4 which is used.

manoharreddyporeddy commented 5 years ago

Giving below way didn't have any effect, not sure why:

File: config.xml

<plugin name="cordova-admob-sdk" spec="../plugins/cordova-admob-sdk">
    <variable name="PLAY_SERVICES_VERSION" value="16.+" />
</plugin>

<plugin name="cordova-plugin-admob-free" spec="0.25.0">
    <variable name="PLAY_SERVICES_VERSION" value="16.+" />
</plugin>
rodrigograca31 commented 5 years ago

I can confirm that PLAY_SERVICES_VERSION does nothing I'm having the same issue.

I was having conflicts with firebase-analytics and thinking it was strange that it was using 11.0.4 even tough I specified +:

cordova plugin add cordova-plugin-admob-free --variable ADMOB_APP_ID="ca-app-pub-ID" --variable PLAY_SERVICES_VERSION="+"
<plugin name="cordova-plugin-admob-free" spec="^0.26.0">
    <variable name="ADMOB_APP_ID" value="ca-app-pub-ID" />
    <variable name="PLAY_SERVICES_VERSION" value="+" />
</plugin>
* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[4]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-clearcut:11.0.4 -> com.google.android.gms:play-services-tasks@[
  11.0.4], but play-services-tasks version was 16.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.firebase:firebase-iid@17.1.2
  -- Project 'app' depends onto com.google.android.gms:play-services-safetynet@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-common@16.1.0
  -- Project 'app' depends onto com.google.android.gms:play-services-clearcut@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-analytics@16.5.0
  -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
  -- Project 'app' depends onto com.google.android.gms:play-services-tasks@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-base@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-ads@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-base@16.0.1
  -- Project 'app' depends onto com.google.firebase:firebase-iid-interop@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@16.5.0
  -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.+

Then I manually set <preference name="PLAY_SERVICES_VERSION" default="+"/> in plugins/cordova-admob-sdk/plugin.xml and all the erros are gone....

I would suggest that we change from 11.0.4 to 17.2.0 but that probably requires a bunch of changes in this plugin.....? or just this line? https://github.com/ratson/cordova-admob-sdk/blob/f6db1b36a23ceee61b7490fccd0ab5ae6ef98adc/plugin.xml#L16

Now that I think about it we are supposed to move to admob-plus right? Apparently it already uses the latest version 17.2.0: https://github.com/admob-plus/admob-plus/blob/packages/cordova/plugin.xml#L17

rodrigograca31 commented 5 years ago

P.S. 11.0.4 is from June 2017!!!! Almost 2 years of improvements! We got to fix this! :smile:

wiseindy commented 4 years ago

I've got it working thanks to the findings of @rodrigograca31 and the readme for plugin cordova-admob-sdk on GitLab

I am using the ionic framework, so the commands have the ionic prefix. If you're not using ionic framework, simply remove ionic from the commands and it should work fine.

This is what I did:

  1. Remove the plugins cordova-plugin-admob-free and cordova-admob-sdk
    
    ionic cordova plugin rm cordova-plugin-admob-free --variable ADMOB_APP_ID="ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx"

ionic cordova plugin rm cordova-admob-sdk


2. Check `package.json` and remove any references to `cordova-admob-sdk` and `cordova-plugin-admob-free`. I had to remove these lines:

"cordova-admob-sdk": "^0.24.1",

... ...

"cordova-admob-sdk": { "PLAY_SERVICES_VERSION": "11.0.4" },


3. Modify your `config.xml` and add this part:

Replace `17.0.0` by whatever version you require. My project needed `17.0.0` because of firebase and it worked for me.

4. Install the plugins

ionic cordova plugin add cordova-plugin-admob-free --variable ADMOB_APP_ID="ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx"

ionic cordova plugin add cordova-admob-sdk



That's it! Your project should build successfully now. Hopefully this works for you.
daniel-linws commented 4 years ago

I have follow the method still not working...

rodrigograca31 commented 4 years ago

@daniel-linws try to change this like to 17 something:

https://github.com/ratson/cordova-admob-sdk/blob/f6db1b36a23ceee61b7490fccd0ab5ae6ef98adc/plugin.xml#L16

Folder PROJECT/plugins/cordova-admob-sdk/

daniel-linws commented 4 years ago

@rodrigograca31

I follow your method but still not working. I just create a new ionic v4 project with latest sdk. and the package.json is listed as below. before adding admob free plugin, I can build and run the app on android studio successfully. but after adding this plugin the following error occur when I run the app.

"Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.+. "

package.json { "name": "tester", "version": "0.0.1", "author": "Ionic Framework", "homepage": "https://ionicframework.com/", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/common": "~8.1.2", "@angular/compiler": "~8.1.2", "@angular/core": "~8.1.2", "@angular/forms": "~8.1.2", "@angular/platform-browser": "~8.1.2", "@angular/platform-browser-dynamic": "~8.1.2", "@angular/pwa": "^0.802.0", "@angular/router": "~8.1.2", "@angular/service-worker": "~8.1.2", "@ionic-native/core": "^5.0.0", "@ionic-native/fcm": "^5.12.0", "@ionic-native/http": "^5.10.0", "@ionic-native/in-app-browser": "^5.10.0", "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic/angular": "^4.7.1", "@ionic/storage": "^2.2.0", "@logisticinfotech/ionic4-datepicker": "^1.4.1", "@ng-bootstrap/ng-bootstrap": "^5.1.0", "@ng-bootstrap/schematics": "^2.0.0-alpha.1", "bootstrap": "^4.0.0", "chart.js": "^2.8.0", "cordova-admob-sdk": "^0.24.1", "cordova-android": "8.0.0", "cordova-ios": "5.0.1", "cordova-plugin-admob-free": "^0.27.0", "cordova-plugin-advanced-http": "^2.1.1", "cordova-plugin-datepicker": "^0.9.3", "cordova-plugin-device": "^2.0.2", "cordova-plugin-fcm-with-dependecy-updated": "^2.4.0", "cordova-plugin-file": "^6.0.2", "cordova-plugin-inappbrowser": "^3.1.0", "cordova-plugin-ionic-keyboard": "^2.1.3", "cordova-plugin-ionic-webview": "^4.1.1", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", "cordova-promise-polyfill": "0.0.2", "cordova-sqlite-storage": "^3.2.1", "core-js": "^2.5.4", "moment": "^2.24.0", "phonegap-plugin-multidex": "^1.0.0", "rxjs": "~6.5.1", "rxjs-compat": "^6.5.2", "tslib": "^1.9.0", "zone.js": "~0.9.1" }, "devDependencies": { "@angular-devkit/architect": "~0.801.2", "@angular-devkit/build-angular": "~0.801.2", "@angular-devkit/core": "~8.1.2", "@angular-devkit/schematics": "~8.1.2", "@angular/cli": "~8.1.2", "@angular/compiler": "~8.1.2", "@angular/compiler-cli": "~8.1.2", "@angular/language-service": "~8.1.2", "@ionic/angular-toolkit": "~2.0.0", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "^5.0.0", "cordova-plugin-device": "^2.0.2", "cordova-plugin-ionic-keyboard": "^2.1.3", "cordova-plugin-ionic-webview": "^4.1.1", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.4.3" }, "description": "An Ionic project", "cordova": { "plugins": { "cordova-plugin-inappbrowser": {}, "cordova-plugin-advanced-http": { "OKHTTP_VERSION": "3.10.0" }, "cordova-sqlite-storage": {}, "cordova-plugin-whitelist": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" }, "cordova-plugin-ionic-keyboard": {}, "cordova-plugin-datepicker": {}, "cordova-plugin-fcm-with-dependecy-updated": {}, "cordova-plugin-admob-free": { "ADMOB_APP_ID": "ca-app-pub-8414190121838781~9456078261" } }, "platforms": [ "android" ] } }

rodrigograca31 commented 4 years ago

after changing the line I mentioned above you probably have to remove and add platform again so that it adds it again to the project with the correct version........

luigi37 commented 4 years ago

Hi all, after trying many options, as I had to ensure my main pluging (phonegap push plugin: https://github.com/phonegap/phonegap-plugin-push) was working properly (and it's on google services 15.0.1) I ended up installing cordova-plugin-admob-free and the MANUALLY looking for every occurrence of string "11.0.4" inside the "platform/android" directory and replacing it with "15.0.1" (change as needed). I stress "manually" because there are few files in which you don't have to change it (you can recognise because it's a list of versions all together). Would be great if this could be sorted just with a --PLAY-SERVICE parameter at installation phase similar to admobpro plugin...

scottopolis commented 4 years ago

Just leaving this here in case it helps, I was getting the "Dependency failing" errors due to different play services versions with cordova 9. In my case it was from phonegap-plugin-push as well as this admob plugin.

Adding the PLAY_SERVICES_VERSION to config.xml as described in the docs did nothing. What worked for me:

  1. cordova plugin rm cordova-plugin-admob-free --variable ADMOB_APP_ID="XXXXXXX"
  2. cordova plugin add cordova-admob-sdk --variable PLAY_SERVICES_VERSION="15.0.1"
  3. cordova plugin add cordova-plugin-admob-free --variable ADMOB_APP_ID="XXXXXXX"

This added this line to my package.json under cordova plugins:

"cordova-admob-sdk": { "PLAY_SERVICES_VERSION": "15.0.1" }

That fixed android builds for me.