Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordova build fails after adding adjust plugin #40

Closed
marcusbesjes opened this issue Apr 26, 2016 · 16 comments
Closed

cordova build fails after adding adjust plugin #40

marcusbesjes opened this issue Apr 26, 2016 · 16 comments

Comments

@marcusbesjes
Copy link

I'm adding the adjust plugin 4.3.0 to a project with only the Android platform. After adding the plugin, running cordova build fails with the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processArmv7DebugResources'.
> Error: more than one library with package name 'com.google.android.gms'

If I create a fresh Cordova project and only add the Adjust plugin, there is no problem building, so I know the error must be following from some sort of conflict with one or more if the existing plugins in my app.

I will continue to debug this problem and I will update when I've figured out exactly which plugin(s) is/are conflicting with adjust.

I was wondering if there is anything that could be done on the adjust plugin level to avoid this type of conflict. Maybe in the way it declares/adds this library?

The complete list of plugins now looks like this:

> cordova plugin ls
acidhax.cordova.chromecast 0.0.1-alpha "Cordova ChromeCast"
com.adjust.sdk 4.3.0 "Adjust"
com.amazon.device.iap.cpt.AmazonIapV2Plugin 1.0.0 "AmazonIapV2"
com.phonegap.plugins.facebookconnect 0.11.0 "Facebook Connect"
cordova-plugin-crosswalk-webview 1.6.1 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-email-composer 0.8.3 "EmailComposer"
cordova-plugin-file 4.1.1 "File"
cordova-plugin-file-transfer 1.5.0 "File Transfer"
cordova-plugin-globalization 1.0.3 "Globalization"
cordova-plugin-inappbrowser 1.3.0 "InAppBrowser"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-splashscreen 3.2.1 "Splashscreen"
cordova-plugin-statusbar 2.1.2 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-plugin-x-socialsharing 5.0.11 "SocialSharing"

running Cordova 6.1.1

@uerceg
Copy link
Contributor

uerceg commented Apr 26, 2016

Hi @marcusbesjes

Maybe some of the plugins is already using that part of Google Play Services which is needed for our SDK. Please check our Google Play Services guide from README: https://github.com/adjust/cordova_sdk/#4-google-play-services

Feel free to follow this part about removing Google Play Services dependency from our plugin and retry.

Let me know if that worked for you.

Cheers

@marcusbesjes
Copy link
Author

marcusbesjes commented Apr 26, 2016

man that really looks like it should fix this, but unfortunately I'm still getting the same error.

I tried to edit the plugins/com.adjust.sdk/plugin.xml in the project and rebuild, and I tried removing the plugin, editing the adjust_4.3.0/plugin.xml file before adding it to the project, and then running cordova plugin add adjust_4.3.0.

But after both cases I still get the same error :(

tnx for the quick reply btw :)

@uerceg
Copy link
Contributor

uerceg commented Apr 26, 2016

Hm, I tried to recreate your plugin list, I think error relates to one of these two plugins:

acidhax.cordova.chromecast 0.0.1-alpha "Cordova ChromeCast"
cordova-plugin-crosswalk-webview 1.6.1 "Crosswalk WebView Engine"

For example, once adding them (just adding them, not using them at all), I am unable to build my app. I am getting following error:

:compileArmv7DebugJavaWithJavac/Users/uerceg/Projects/Cordova/AdjustExample/platforms/android/src/acidhax/cordova/chromecast/Chromecast.java:12: error: package com.google.android.gms.cast does not exist

followed by bunch of errors saying that different symbols can't be found or that some particular package doesn't exist, etc.

Any idea how to solve this maybe so that I might be able maybe to reproduce error you're getting?

@marcusbesjes
Copy link
Author

marcusbesjes commented Apr 26, 2016

I'm adding those plugins in the following way:

cordova plugin add cordova-plugin-crosswalk-webview@1.6.1 --variable XWALK_VERSION="14"
cordova plugin add https://github.com/exozet/cordova-chromecast.git

then I'm able to build

@marcusbesjes
Copy link
Author

Adding the Adjust plugin after those two already gives the > Error: more than one library with package name 'com.google.android.gms' error

@marcusbesjes
Copy link
Author

marcusbesjes commented Apr 26, 2016

I can build if I remove the acidhax.cordova.chromecast plugin and add the adjust plugin, so that is where the conflict comes from.

@uerceg
Copy link
Contributor

uerceg commented Apr 27, 2016

Okay, managed to reproduce the error you are facing, indeed with acidhax.cordova.chromecast plugin and indeed removing -analytics dependency from plugin.xml didn't help.

It looks like things in build.gradle start to conflict after adding/removing different plugins. I managed to fix this in my app by doing this:

cordova platform remove android
cordova platform add android

After that, my app was successfully built with acidhax.cordova.chromecast and com.adjust.sdk plugin. Seems dummy, but worth a try.

Let me know if this worked for you.

@marcusbesjes
Copy link
Author

alas, it doesn't seem to have any effect over here, I removed and added the android platform both on my full list of plugins and on the test project with only chromecast and adjust, both still give the same error. I also tried removing the plugins and adding them in different orders.

@uerceg
Copy link
Contributor

uerceg commented Apr 27, 2016

Hm. :) Funky stuff. After retrying, would be interesting if you can check following part after doing:

cordova build android

When building, gradle builds stuff and among other lines, you can see these:

...
:prepareComGoogleAndroidGmsPlayServicesAds750Library
:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library
:prepareComGoogleAndroidGmsPlayServicesBase750Library
:prepareComGoogleAndroidGmsPlayServicesCast750Library
:prepareComGoogleAndroidGmsPlayServicesGcm750Library
...

If you build your app w/o our plugin, they look exactly like this, because it looks like that acidhax.cordova.chromecast forces 750 version. In this moment, app is built successfully.
But once our plugin is added, these lines look like:

...
:prepareComGoogleAndroidGmsPlayServicesAds750Library
:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library
:prepareComGoogleAndroidGmsPlayServicesBase750Library
:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:prepareComGoogleAndroidGmsPlayServicesCast750Library
:prepareComGoogleAndroidGmsPlayServicesGcm750Library
...

Since our plugin aims to put latest -analytics version in the app, looks like it changes parts of this from 750 to 840. And as long as you have this mixup, build fails.

Now, to fix this, try this:

  1. Remove android platform from your app.
  2. Edit our plugin.xml and comment that line which includes -analytics part of Google Play Services and save it.
  3. Add android platform back to your app.
  4. Clean
  5. Build

Let me know if it worked in this way. :)

@tvervest
Copy link

Hey @uerceg,
First of all, thanks for the lightning replies on this issue!

I'll be taking over the issue from Marcus as I'm the engineer working on our automated build script(s).

It seems you're right, I have the same lines in the build log and removing the Google Play Services from the plugin.xml file results in a successful build.

It would be a great feature if we could specify the Google Play Services version to use when installing the plugin. This would also prevent problems should Google break the Google Play Services interface in a future release. We've faced numerous problems with wildcard version numbers in previous Cordova releases, so we're very keen on fixating the version so that we can test before updating to a new version.

For the time being we'll just create a fork in which we'll modify the plugin.xml, but I'd love to hear what your thoughts are on a feature to allow users to fixate the version :)

@tvervest
Copy link

P.S. I've tried adding a preference field to the plugin, but for some reason the variable doesn't get replaced with the specified value.

I've applied these changes;

  • added a preference called GOOGLE_PLAY_SERVICES_VERSION to the plugin.xml file within the android platform
  • replaced + version with $GOOGLE_PLAY_SERVICES_VERSION

Adding the plugin with cordova plugin add <path to fork> --arguments GOOGLE_PLAY_SERVICES_VERSION="7.5.0" and re-adding the android platform now results in a gradle file with the line compile "com.google.android.gms:play-services-analytics:$GOOGLE_PLAY_SERVICES_VERSION". Maybe you have an idea why Cordova doesn't replace the variable?

@uerceg
Copy link
Contributor

uerceg commented May 10, 2016

Hi @tvervest

And sorry for delayed answer. Making possibility for users to pass the value of Google Play Services version sounds like an interesting idea.

I have tried to do the same thing as you, but no luck either. If I try to declare -analytics dependancy in plugin.xml like this:

<!-- .... -->

<preference name="GPS_VERSION" />

<!-- .... -->

<!-- Android -->
<platform name="android">
    <!-- .... -->
    <framework src="com.google.android.gms:play-services-analytics:$GPS_VERSION" />
</platform>

<!-- .... -->

and if I add our plugin with:

cordova plugin add ~/parth/to/cordova_sdk/ --variable GPS_VERSION=8.4.0

I indeed get 8.4.0 assigned to GPS_VERSION variable in ios.json and android.json. If I try to assign that variable ($GPS_VERSION) to what ever value I want to write in AndroidManifest.xml, it works. But trying to assign its value to build.gradle file as part of this line:

<framework src="com.google.android.gms:play-services-analytics:$GPS_VERSION" />

doesn't seem to work for some reason.

Did you maybe find a way to make it work?

Cheers

@tvervest
Copy link

Hey @uerceg, that was exactly where I got stuck :)

I haven't figured out why it didn't work, but I'm afraid it might be a bug/feature of Cordova. It seems the --variable value injection simply doesn't apply to the entire config.

@uerceg
Copy link
Contributor

uerceg commented May 10, 2016

Yep, that was pretty much my conclusion after trying to make this happen today. :) I will ping you in here if I manage to find solution for it.

Other than that, any reason still not to close this issue?

@tvervest
Copy link

Great, if I ever find out what was going on exactly I'll update this as well 👍

No reasons not to close this issue, feel free to do so :)

@uerceg
Copy link
Contributor

uerceg commented May 13, 2016

👍

Cheers!

@uerceg uerceg closed this as completed May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants