More than one library with package name 'com.google.android.gms' even with new project

540 views
Skip to first unread message

Nick Fenwick

unread,
Feb 17, 2016, 10:58:08 AM2/17/16
to phonegap
I ran into this problem as I tried to update an old Phonegap project we built in 2014 to the latest phonegap platform.  The plugin ecosystem has changed, so I removed the old `org....` plugins and added `cordova-plugin-....` instead.  I'm developing using CLI tools on Ubuntu linux and targetting android platform 22 at the moment (ios to follow).  My phonegap tools are version 5.5.2.

We use Google Analytics, so I added `cordova-plugin-analytics` and this seemed to require `cordova-google-play-services`, and we also use PushPlugin for OTA message push to the device, now the build ends with:

    Error: more than one library with package name 'com.google.android.gms'
   
      You can temporarily disable this error with android.enforceUniquePackageName=false
   
      However, this is temporary and will be enforced in 1.0

This happens even with a completely new project:

    $ phonegap create test2
    $ cd test2
    $ phonegap platform add android
    $ phonegap run -d android
    .. this runs on the device fine ..
    $ phonegap plugin add cordova-plugin-analytics
    $ phonegap plugin add cordova-plugin-pushplugin
    $ phonegap run -d android
    .. this fails to build with the above error ..

If I search all *.jar files under `plugins` for com.google.android.gms, the only jar that contains it is:

    ./cordova-google-play-services/libs/google-play-services_lib/libs/google-play-services.jar

The plugin list on the test project is now:

    $ phonegap plugin list
    cordova-google-play-services 25.0.0 "Google Play Services for Android"
    cordova-plugin-analytics 1.3.3 "Google Analytics Plugin"
    cordova-plugin-device 1.1.1 "Device"
    cordova-plugin-globalization 1.0.2 "Globalization"
    cordova-plugin-pushplugin 2.6.1 "PushPlugin"
    cordova-plugin-whitelist 1.2.1 "Whitelist"

I've been researching this 'more than one library with package name...' error, and there is advice on the web about removing your `android` platform and adding it again (`phonegap platform rm android ; phonegap platform add android`) and similar, but this problem occurs even with a completely fresh project.

So, is the error message correct?  Should I try to fix it or work around it? (e.g. editing setting `enforceUniquePackageName=false` and if so, where do I do that in a Phonegap project?)  Is one of the plugins buggy and somehow the jar is being included on a classpath twice or similar horrible shennanigans?

This guy https://groups.google.com/forum/#!searchin/phonegap/more$20than$20one$20library$20with$20package$20name/phonegap/AzW4Xv5O524/OJ8-x1uGAAAJ seemed to have a similar problem but he's on Windows and he seems to have hit a dead end.

Losing a lot of time on this, any advice appreciated.
Nick

Kerri Shotts

unread,
Feb 17, 2016, 11:36:34 AM2/17/16
to phonegap
I took a quick look at the plugin.xml files for each plugin, and I suspect it's a bugged plugin. Both require Google Play services, but are using two separate plugins to try and accomplish it. Interestingly, the second plugin (pushplugin) is using a deprecated plugin for Play Services. I suspect that's where the conflict is arising.

I would guess that if you remove one or the other plugins, that you'd be able to build just fine. (Although of course your app might break since not all the plugins are available.) 

On Wednesday, February 17, 2016 at 9:58:08 AM UTC-6, Nick Fenwick wrote:
...

Nick Fenwick

unread,
Feb 17, 2016, 10:25:46 PM2/17/16
to phonegap
Right Kerry, if I remove either plugin (analytics or pushpugin) the build succeeds, but our app absolutely requires both of these features.  I considered alternative 'push' plugins but to make a leap like that just because the pushplugin one is 'buggy' (or it might be analytics which is 'buggy', I really can't tell) would be a waste of effort, if the plugins can be bugfixed to resolve the dependency issue then our app would Just Work (tm).

I've seen rumbles on the net since November or earlier last year, and really hoped this issue would be resolved by now.  Is no-one building projects with these two extremely common features in them?

I don't know phonegap plugin architecture well at all, I could not see how the two define their dependencies on Google Play services, or if I did, I couldn't see how to change things to make it work.  I have two days to deliver a new version of our app and this is no time to learn phonegap plugin development.  I'm going to try rolling back our project to the old versions of everything and hope the build succeeds.

I tried cordova-plugin-push, which unlike its 'pushplugin' sibling claims to have no dependencies on other plugins .. but then 'phonegap run -d android' build fails with 'java.util.zip.ZipException: duplicate entry: com/google/android/gms/dynamic/zza.class'

This whole experience is very painful.

If you or anyone can suggest how to quick fix the simple Hello World project I described below so that it builds using the latest analytics and pushplugin plugins, I'd be extremely grateful, and perhaps we can push the fix to the plugin projects once we know what to suggest?

Nick

Simon MacDonald

unread,
Feb 17, 2016, 11:03:54 PM2/17/16
to phonegap
Hey Nick,

I maintain the phonegap-plugin-push repo, this is the one that replaces cordova-plugin-pushplugin as the code that is based off of is deprecated. The plugin the PhoneGap team maintains handles dependencies on Android via Gradle which is the way to go. Sadly, the analytics plugin is not up to date but if you look at:

you'll see my explanation of how to get the two working side by side including a couple of alternative analytics plugins that doe things the right way.

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Fenwick

unread,
Feb 18, 2016, 12:23:01 AM2/18/16
to phonegap
Thank you Simon, I didn't realise even cordova-plugin-pushplugin should be considered deprecated (as you say, because it's based on deprecated code).  Appreciate the pointer that it's cordova-plugin-analytics that's causing the problem.  I will try to use this advice before our deadline.

Meantime I've successfully reverted my upgrades and am building successfully again on old versions of the platform (android 3.6.3) and the old com.adobe.plugins.GAPlugin and com.phonegap.plugins.PushPlugin just to get our core app functionality complete and buildable.

Will try to feedback here as and when I try your advice.  Thanks again,
Nick
Reply all
Reply to author
Forward
0 new messages