2
votes

I am facing thi error in installing AdMob cordova plugin on android https://github.com/floatinghotpot/cordova-plugin-admob ,, The plugin is installed and works fine with iOS platform, but it gives this error on android.

My Enviroment:

Fetching plugin "https://github.com/floatinghotpot/cordova-plugin-admob.git" via git clone Installing "com.rjfun.cordova.plugin.admob" for android Fetching plugin "com.google.admobsdk" via plugin registry Installing "com.google.admobsdk" for android Fetching plugin "[email protected]" via plugin registry Failed to install 'com.google.admobsdk':Error: Expected fetched plugin to have ID "[email protected]" but got "com.google.playservices". at checkID (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:116:19) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:99:24 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13) at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44 at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17) at process._tickCallback (node.js:419:13) Failed to install 'com.rjfun.cordova.plugin.admob':Error: Expected fetched plugin to have ID "[email protected]" but got "com.google.playservices". at checkID (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:116:19) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:99:24 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13) at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44 at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17) at process._tickCallback (node.js:419:13) Error: Expected fetched plugin to have ID "[email protected]" but got "com.google.playservices". at checkID (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:116:19) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:99:24 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13) at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:574:44 at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17) at process._tickCallback (node.js:419:13)

Any ideas?! Thanks in advance

2

2 Answers

4
votes

The simple answer is:

You need upgrade to cordova CLI v4.0, just run:

sudo npm install cordova -g

The detailed answer is:

The root cause of this failure is, cordova CLI v3.5 does not correctly recognize the following dependency in plugin com.google.admobsdk.

<dependency id="[email protected]"/>

You may ask, why @19.0.0 is added?

It's used to specify an exact version, and keep it compatible with cordova CLI and Intel XDK.

As the default com.google.playservices (@21.0.0) cannot be handled by Intel XDK (at least so far, when this answer is being posted), while version [email protected] can be correctly handled by Intel XDK.

Some bugs in cordova v3.5 causes this problem and has been fixed in cordova v4.0, mentioned as "Pinned dependencies" in the release notes.

See release notes: http://cordova.apache.org/announcements/2014/10/16/cordova-4.html

So, please upgrade to cordova CLI v4.0, it will be much easier.

If any issue, please ask in the project issue tracker page, you will be supported timely.

3
votes

I'm using this one and works fine for me: https://github.com/appfeel/admob-google-cordova

cordova plugin add cordova-admob

If you run in phonegap build, then:

<gap:plugin name="phonegap-admob" source="npm"/>