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

Fix duplicate Android packages being linked #43

Closed
grabbou opened this issue Dec 10, 2018 · 4 comments · Fixed by #81
Closed

Fix duplicate Android packages being linked #43

grabbou opened this issue Dec 10, 2018 · 4 comments · Fixed by #81

Comments

@grabbou
Copy link
Member

grabbou commented Dec 10, 2018

Recent commit updated Android part of the link mechanism to use "implementation" instead of "compile" to align with what Gradle recommends: c6c34a2

Unfortunately, it breaks the detection of an already installed packages.

The way "link" detects an installed package on Android is by looking for "compile(XXX)" inside build.gradle. We don't have a sophisticated tool for parsing and reading Gradle files, hence we use a really simple RegExp to look for informations that we want. It was always meant to be a temporary solution, so we are going to work on resolving that in the nearest future.

Meanwhile, what happens is that now, after the update, "link" will look for "implementation(XXX)" string instead to indicate that the given package is already linked.

This means that when "link" command is run on an existing codebase that still uses "compile" (e.g. just updated to a new project), it will not treat such project as installed and will add it once again, this time using implementation(XXX). This results with duplicate packages.

We should teach link/android/isInstalled.js to return "true" in both scenarios when "compile" and "implementation" are present. Both are valid right now in Gradle v3 (with "compile" being obsolete).

We should also make sure that "unlink" can handle both cases.

CC: @thymikee @dulmandakh (original reviewer of the PR)

@grabbou
Copy link
Member Author

grabbou commented Dec 10, 2018

Also - question - is the Gradle plugin version enforced by React Native? I am not really familiar, need to check, but... is the newer plugin version required, otherwise project will not build?

If not, I can see scenarios when v3 is not used (hence "implementation" is not even present). In that case, we should detect Gradle version before even proceeding.

@dulmandakh
Copy link
Contributor

IIRC, we landed Android Gralde Plugin 3.x in RN 0.56 and we must be using implementation because Gradle will show deprecation warning if you use compile or compileOnly. So we should've fixed linking a long before.

Usually, Android Gradle Plugin is versioned as same as Android Studio and used in it. And Google adds features, enhancements in it, so it's best to use latest version. Also Gradle version upgrades are mostly non-breaking, except 2.x to 3.x which require some manual work.

FINAL: Use Gradle 3.x

@thymikee
Copy link
Member

I'd like to add one more case where new CLI reports a duplicate:

implementation (project(':react-native-device-info')) {
    exclude group: 'com.google.android.gms'
}

Seems like the extra paren(s) before project is not taken into consideration

@Esemesek Esemesek assigned Esemesek and unassigned Esemesek Jan 9, 2019
@ferrannp
Copy link
Member

ferrannp commented Jan 9, 2019

There will be also an issue if you use:

implementationDebug
compileDebug
compileWhateverVariantYouWant
implementationVariantYouWant

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

Successfully merging a pull request may close this issue.

5 participants