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

Failed to install plugin for ionic project, PLAY_SERVICES_VERSION not found #276

Open zdd opened 5 years ago

zdd commented 5 years ago

Got the following error when install this plugin, I am wondering where is variable PLAY_SERVICES_VERSION defined? thanks.

D:\git\ionic\zhuanshuchaxun>ionic cordova plugin add cordova-plugin-admob-free
> cordova plugin add cordova-plugin-admob-free --save
Installing "cordova-plugin-admob-free" for android
Installing "cordova-promise-polyfill" for android
ANDROID_HOME=D:\android_sdk\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_cl3g8k7q0v8temg580r4r873y.run(D:\git\ionic\zhuanshuchaxun\platforms\android\build.gradle:141)
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:clean
:CordovaLib:clean

BUILD SUCCESSFUL in 8s
2 actionable tasks: 2 executed
Installing "cordova-admob-sdk" for android
ANDROID_HOME=D:\android_sdk\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_cl3g8k7q0v8temg580r4r873y.run(D:\git\ionic\zhuanshuchaxun\platforms\android\build.gradle:141)
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:clean
:CordovaLib:clean UP-TO-DATE

BUILD SUCCESSFUL in 2s
2 actionable tasks: 1 executed, 1 up-to-date
Subproject Path: CordovaLib
ANDROID_HOME=D:\android_sdk\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_cl3g8k7q0v8temg580r4r873y.run(D:\git\ionic\zhuanshuchaxun\platforms\android\build.gradle:141)
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\git\ionic\zhuanshuchaxun\platforms\android\build.gradle' line: 256

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'PLAY_SERVICES_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Failed to install 'cordova-plugin-admob-free': Error: cmd: Command failed with exit code 1
    at ChildProcess.whenDone (D:\git\ionic\zhuanshuchaxun\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
Error: cmd: Command failed with exit code 1
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
[ERROR] An error occurred while running subprocess cordova.

        cordova plugin add cordova-plugin-admob-free --save exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

D:\git\ionic\zhuanshuchaxun>

error happen in code below in file 'build.grale' under forder platfroms/android. seems like gradle can't find this variable.

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: "CordovaLib"))
    compile "com.android.support:support-v4:24.1.1+"
    compile "com.google.android.gms:play-services-base:$**PLAY_SERVICES_VERSION**"
    compile "com.google.android.gms:play-services-ads:$**PLAY_SERVICES_VERSION**"
    // SUB-PROJECT DEPENDENCIES END
}
zdd commented 5 years ago

environment info

D:\git\ionic\zhuanshuchaxun>ionic info

Ionic:

   ionic (Ionic CLI)  : 4.0.1 (C:\Users\SuperDong\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 7.0.0
   Cordova Platforms     : android 6.4.0

System:

   Android SDK Tools : 26.0.2
   NodeJS            : v8.11.2 (C:\Program Files\nodejs\node.exe)
   npm               : 5.6.0
   OS                : Windows 10

Environment:

   ANDROID_HOME : D:\android_sdk\sdk
zdd commented 5 years ago

It seems this lib is not work on Android, does anyone ever make this work on Android?

lolaswift commented 5 years ago

@zdd Try downgrading your cordova-android version from 6.4.0 to 6.3.0 and add the following lines to your build.gradle file.

// SUB-PROJECT DEPENDENCIES END compile "com.google.android.gms:play-services-analytics:+" compile "com.google.android.gms:play-services-base:+" compile "com.google.android.gms:play-services-ads:+" compile "com.google.gms:google-services:+" compile "com.google.android.gms:play-services-tagmanager:+"

zdd commented 5 years ago

@zdd Try downgrading your cordova-android version from 6.4.0 to 6.3.0 and add the following lines to your build.gradle file.

// SUB-PROJECT DEPENDENCIES END compile "com.google.android.gms:play-services-analytics:+" compile "com.google.android.gms:play-services-base:+" compile "com.google.android.gms:play-services-ads:+" compile "com.google.gms:google-services:+" compile "com.google.android.gms:play-services-tagmanager:+"

Thanks, but downgrade is not a good idea.

rodrigograca31 commented 5 years ago

I'm facing this issue in 2019... Using cordova-android@7.1.1, I already tried 7.1.4 and 8.0.0 and had the same issue

I suspect its related to #126 but I just removed Firebase and still have the same issue... :cry:

rodrigograca31 commented 5 years ago

Further inspection leads me to believe its a problem in this plugin it self. as mentioned in #147 creating a new project shows this problem.

Steps to reproduce it:

ionic start myApp tabs
cd myApp/
ionic cordova plugin add cordova-plugin-admob-free --variable ADMOB_APP_ID="ID" --variable PLAY_SERVICES_VERSION="+"
ionic cordova platform add android@^7.1.1
ionic cordova run android --device

I will try a few more "combinations" ....

rodrigograca31 commented 5 years ago

More debugging info: It compiles on my other machine. I'm using a different gradle version between them: export PATH=${PATH}:/opt/android-studio/gradle/gradle-5.2/bin vs export PATH=${PATH}:/opt/android-studio/gradle/gradle-4.10.1/bin

but I made them both use 5.2 and the problem still exists but my other machine can compile without erros...

rodrigograca31 commented 5 years ago

Working machine environment:

Ionic:

   ionic (Ionic CLI)             : 4.10.2 (/home/unknown/npm/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.1.1
   @angular-devkit/build-angular : 0.13.5
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.5
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 5 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/unknown/Android/Sdk/)
   NodeJS            : v8.10.0 (/usr/bin/node)
   npm               : 6.7.0
   OS                : Linux 4.15

Non working machine environment:

Ionic:

   ionic (Ionic CLI)             : 4.11.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.1.1
   @angular-devkit/build-angular : 0.13.5
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.5
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 7.0.1
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 5 other plugins)

System:

   Android SDK Tools : 26.1.1 (/media/ntfs/android-sdk-linux)
   NodeJS            : v8.11.3 (/usr/local/bin/node)
   npm               : 6.9.0
   OS                : Linux 4.15

Humm :thinking: :thinking: :thinking: cordova cli seems to be the biggest difference....

rodrigograca31 commented 5 years ago

Ok. After updating cordova everything works. npm install cordova -g

cordova -v
8.1.2 (cordova-lib@8.1.1)

If this solves the problem thumbs up this comment! Maybe it can also solve #147 ?

mkalyon commented 3 years ago

I solved like that Firstly copy cordova-admob-sdk in your plugin directory of your app Paste it to diffrent directory like that c:\plugins remove plugin cordova plugin rm cordova-admob-sdk --force open plugin.xml in c:\plugins\cordova-admob-sdk change to

and save

return your app cli cordova plugin add c:\plugins\cordova-admob-sdk cordova build