Cannot build after adding Ionic OneSignal


I have added the plugin OneSignal for push notifications. (found it on the ionic market place, it looked cool)

However, since I added it I can no longer build my apk!

The error is "more than one library with package name ‘’ "

And indeed after checking my build.gradle in my android folder, I found:
compile ""
compile “”

But I did remove the plugin ionic analytics! Yet it sticks to my build.gradle, even when I erase it/delete the line, it comes back when I try to build…

Any help would be much appreciated,


Can you run ionic plugin list and ionic -version and post the results. This will help us reproduce the issue. Could you also post the full error from the console you’re seeing?

play-services-gcm and play-services-analytics isn’t the cause of your build error. They are not conflicting as they are just parts of gms (Google Play services).

If you still running into build issues after removing a plugin you might have to do a clean build to reset gradle. I have seen issues with other plugins before as well where a clean build is needed.


I’m getting the same error.

when i run cordova plugin list i got: 23.0.0 "Google Play Services for Android"
com.googlemaps.ios 1.9.2 "Google Map iOS SDK for Cordova"
cordova-plugin-whitelist 1.0.0 "Whitelist"
onesignal-cordova-plugin 1.9.0 "OneSignal Push Notifications"
org.apache.cordova.statusbar 0.1.10 "StatusBar" 1.2.5 "phonegap-googlemaps-plugin"
plugin.http.request 1.0.4 "phonegap-http-request"

@eduzera The '' includes '' as an ANT like dependency. I don’t see an updated Google Map plugins using the new gradle way of including Google Play services so you will need to use our compat version instead.

Please follow our Clean Build Guide and instead of adding 'onesignal-cordova-plugin' add 'onesignal-cordova-plugin-pgb-compat'. Lastly you will also need to the run the following:
ionic plugin add cordova-plugin-android-support-v4



Thanks for your reply.

I tried already the clean build, without success.

Here is my ionic plugin list:

com.ionic.keyboard 1.0.4 "Keyboard"
cordova-plugin-camera 1.2.0 "Camera"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-deploy 0.3.0 "IonicDeploy"
onesignal-cordova-plugin 1.9.0 "OneSignal Push Notifications"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"

And here is my ionic version: 1.6.4

I noticed the build works today after deleting the plugin android-support (forgot the full name)

But I believe it’s needed for onesignal to work… Or is it not?

I’m testing a completely blank app with the OneSignal plugin and I am getting the aforementioned error as well. If I use the cordova-plugin-pgb-compat version of the plugin the app builds but it seems that notificationOpenedCallback() is never actually getting called, any ideals?

λ ionic -v


λ cordova -v


λ ionic plugin

com.ionic.keyboard 1.0.4 "Keyboard"
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-whitelist 1.0.0 "Whitelist"
onesignal-cordova-plugin 1.9.0 "OneSignal Push Notifications"

λ ionic build android

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find
     Searched in the following locations:
     Required by:
   > Could not find
     Searched in the following locations:
     Required by:

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

                    throw e;
Error code 1 for command: cmd with args: /s /c "c:\Dev\ExactSupportCentre\platforms\android\gradlew cdvBuildDebug -b c:\Dev\ExactSupportCentre\platforms\android\build.gradle -Dorg.gradle.daemon=true"
Error: c:\Dev\ExactSupportCentre\platforms\android\cordova\build.bat: Command failed with exit code 1
    at ChildProcess.whenDone (C:\Users\CHRISM~1\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

I think I’ve figured it, just waiting for SDK manager to finish updating.

I’ve got two versions of the SDK on my computer, one that I installed myself for cordova, the other that the Android studio bundles. Turned out I was updating the wrong instance of the SDK, so will report back once I’ve managed to install the Google Play Services package for the correct SDK

OK, I had to install some additional packages through the SDK manager to get things going.
Under the extras folder,
Google Play Services
Google Repository
Android Support Repository (Android Support Library was already installed for me)

@CT14_IT In the SDK Manager the “Android Support Repository” and “Google Repository” are needed. This is shown on step 3. Android of our setup guide.

"cordova-plugin-pgb-compat" should only be used if you have other plugins that include either the “Android Support Library” or “Google Play services” that haven’t been updated to use the new gradle dependencies like the OneSignal plugin does. We have a OneSignal Compatibility guide you can see for when our compat plugin should be used instead of our normal one.

You said that notificationOpenedCallback() was not firing for you when opening a notification. Is that working for you now?


Hi @OneSignal, yeah all working now. I couldn’t figure out why it wasn’t working, I had added the correct dependencies through SDK Manager, but it seemed it was being ignored.

The issue was, I was updating the wrong instance of the Android SDK, it seems to have caught a few people out in general for Cordova/Android dev.


@pierro I added each of the plugins you listed to a new ionic project and was not able to reproduce a build issue. Are you seeing a compile error when if you add these plugins to a brand new project?

I noticed some of your plugin versions are older, what version of Cordova do you have installed. You can run cordova -version to see this. We recommend being on version 5.0 or later. You can update Cordova by running npm install -g cordova then double check it with -version.

Correct, OneSignal requires both the “Android Support Library” v4 and “Google Play services”. If you’re missing either one in the APK a user will show up on the OneSignal dashboard however they will show as unsubscribed.



For reasons I don’t quite comprehend, it is now working.

I don’t even have the googlel play services or android support library in my cordova plugin anymore, but it’s working.

I guess they are hidden in some config/gradle/whatever files somewhere…

Here is my cordova plugin list:

com.ionic.keyboard 1.0.4 "Keyboard"
cordova-plugin-camera 1.2.0 "Camera"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-deploy 0.3.0 "IonicDeploy"
onesignal-cordova-plugin 1.9.0 "OneSignal Push Notifications"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"

@pierro Good to hear your up and running now. You won’t see Google Play Services or the Android Support library listed under cordova plugin list as they are being added as gradle dependencies. You will see the following line in <project-root>/platforms/android/build.gradle.

compile ""
compile ""

These depend on the Android Support Library so you don’t see these listed even in the gradle fiel. These are both pulled from the the Android SDK by gradle which is why these are required to be installed and updated.


Mine, is successfully build when adding

“onesignal-cordova-plugin-pgb-compat” rather than “onesignal-cordova-plugin”,

but the other problem was

“cannot read property OneSignal of undefined on ionic ready”

btw if I just simply using “onesignal-cordova-plugin”, the BUILD will be error.

Here are my “cordova plugin” when using default onesignal cordova plugin:

cordova-plugin-android-support-v4 21.0.1 "Android Support v4"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.3.0 "File Transfer"
cordova-plugin-googleplayservices 19.0.3 "Google Play Services for Android"
cordova-plugin-whitelist 1.0.0 "Whitelist"
onesignal-cordova-plugin 1.9.2 “OneSignal Push Notifications”

Please Help. :wink:

Same here,

m list plugin is:

cordova-plugin-cocoapod-support 1.3.0 "Cordova CocoaPods Dependency Support"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.7 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova.plugins.diagnostic 3.6.7 "Diagnostic"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 2.2.0 "OneSignal Push Notifications"
phonegap-plugin-push 1.10.5 “PushPlugin”