Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

support-v4 dependency fetches alpha version #480

Closed
fredgalvao opened this issue Jun 7, 2017 · 20 comments
Closed

support-v4 dependency fetches alpha version #480

fredgalvao opened this issue Jun 7, 2017 · 20 comments
Labels

Comments

@fredgalvao
Copy link

Expected Behaviour

Plugin to coexist with other plugins that depend on any android-support module and not fetch unstable versions of said dependencies.

Actual Behaviour

jeduan's facebook4 plugin is broken as we speak for anyone also using this or any other plugin that uses too-loose dependency requirements like compile 'com.android.support:support-v4:+'. Furthermore, risking using an unstable and unreleased version of a library is an anti-feature.
Specing at least a major version is recommended.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

jeduan/cordova-plugin-facebook4#507 provides them (just installing both plugins should sufice).

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Not applicable

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Not applicable

Cordova CLI version and cordova platform version

Not applicable

Plugin version

Since 5.0.0, it seems:

Sample Code that illustrates the problem

Not applicable

Logs taken while reproducing problem

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:34 to override.
@fredgalvao
Copy link
Author

To be fair, I do think this is something either gradle or the android are to blame. Their repository should handle it not leaking an alpha version into dependency management unless specified explicitly.

@Ross-Rawlins
Copy link

+1

@pom421
Copy link

pom421 commented Jun 14, 2017

Same bug here.
The latest version of barcode-scanner (6.0.6) and diagnostic (3.6.5) are become incompatible.

$ cordova build android

* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
  	is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
  	Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

I had to to downgrade diagnostic plugin to make it work which is not satisfactory.

@lumitor2
Copy link

lumitor2 commented Jun 14, 2017

Solved this build issue for me. You can give it a try.

Put it to the bottom of platforms/android/build.gradle
configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> if (details.requested.group == 'com.android.support') { //prefer different version which contains some necessary fixes details.useVersion '25.3.1' } } }

@fredgalvao
Copy link
Author

@macdonst This is the same base issue as the conflict between push and googleplus.

@macdonst
Copy link
Member

@fredgalvao yeah, I spent the afternoon on this with the push plugin and could not get the magic incantation. I need to pull in some more folks on this.

@fredgalvao
Copy link
Author

@macdonst You mean you're trying to see why gradle is picking alpha versions?

For the issue at hand, I don't see why not just change from:
compile 'com.android.support:support-v4:+'
to
compile 'com.android.support:support-v4:25+'.

Bold open versioning is always dangerous, even if gradle wasn't spitting alpha versions we could get a major bump with breakages.

@macdonst
Copy link
Member

@fredgalvao in general I'm trying to get plugins that specify + to co-exist with 25+. For the plugins under our control it's easy to pin versions but I want things to work with third parties as well.

@tavojavi
Copy link

tavojavi commented Jun 16, 2017

+1

For people just looking to have a succesful build while solving in a clever way, I made it by making a change in:
cordova\plugins\phonegap-plugin-barcodescanner\src\android\barcodescanner.gradle
as fredgalvao, it was not too obvious to me where to do the change.

@dpa99c
Copy link

dpa99c commented Jun 16, 2017

@macdonst I've been encountering the same problem with 3rd party plugins - making local changes within plugins/ does not work well in a CI environment.

However, I think I've found a solution based on this SO answer which uses an extra bit of Gradle config to override any existing versions specified.
I've tried it out in a couple of test cases and it seems to work so I've created a plugin which wraps it up and makes it easy to install: cordova-android-support-gradle-release.
It seems to do the job in my problematic projects and in the test cases I've created, so give it a go and see if it works for you.

@chr4ss1
Copy link

chr4ss1 commented Jun 19, 2017

dpa99c, that did the trick for me, thanks.

@FlossyWeb
Copy link

@dpa99c You saved my day bro ! Thanks a lot...

@danishin
Copy link

danishin commented Jul 20, 2017

@dpa99c Thank you, you saved my night :) Perhaps you should put a link to that repo in dpa99c/cordova-diagnostic-plugin?

EDIT: I see you already did :] https://github.com/dpa99c/cordova-diagnostic-plugin#gradle-version-collisions

@danilopolani
Copy link

Any update about this? Without an external plugin or overriding build.gradle?

@fredgalvao
Copy link
Author

I'd also like plugin authors in general to use a direct/explicit approach to this issue, instead of us having to rely on a plugin to solve conflicts on specific packages. There aren't that many possible scenarios, and so I think it's worth the little effort for us to keep things stable (by simply not including alpha versions, at the very least).

@rodrigocnovos
Copy link

thanks @dpa99c, you save my project!

@iwan-uschka
Copy link

Thanks @dpa99c, but one more question:

I also use cordova-plugin-facebook4@1.9.1 and phonegap-plugin-barcodescanner@6.0.8 in my project. Til yesterday everything worked fine. Today i got the error described at jeduan/cordova-plugin-facebook4#507.

To fix this, i installed the plugins cordova-android-play-services-gradle-release and cordova-android-support-gradle-release.

But i get an error:

Execution failed for task ':transformClassesWithDexForDebug'.

I think it's because i don't include cordova-plugin-facebook4@1.9.1 and phonegap-plugin-barcodescanner@6.0.8 within the package.json but in the config.xml to define some attributes:

  <plugin name="cordova-plugin-facebook4" spec="cordova_plugins/cordova-plugin-facebook4">
    <variable name="APP_ID" value="XYZ"/>
    <variable name="APP_NAME" value="XYZ"/>
  </plugin>
  <plugin name="cordova-plugin-camera" spec="cordova_plugins/cordova-plugin-camera">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="This app requires camera access to function properly."/>
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="This app requires photo library access to function properly."/>
  </plugin>
  <plugin name="phonegap-plugin-barcodescanner" spec="cordova_plugins/phonegap-plugin-barcodescanner">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="This app requires camera access to function properly."/>
  </plugin>

If i include cordova-plugin-facebook4@1.9.1 and phonegap-plugin-barcodescanner@6.0.8 via package.json everything works fine without any error.

Does anybody have an idea what to do in this case? You can't use the facebook plugin without ID and name of your app.

@syns2191
Copy link

@dpa99c

thanks,, you save my day

@stale
Copy link

stale bot commented Jun 7, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 7, 2018
@stale stale bot closed this as completed Jun 14, 2018
@lock
Copy link

lock bot commented Jul 14, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests