-
Notifications
You must be signed in to change notification settings - Fork 127
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Add gradle plugin and androidX versions into project-level gradle #151
Comments
Useful discussion I think Do we need to specify these version? Per the linked discussion, I'm not aware of a solution that currently meets all use cases and is better than specifying library-specific versions in a gradle-consumable way, somehow. We're currently using android/build.gradle::ext{} scope variables for that in projects, and it works okay. Where to specify the versions if we need to specify them? The list of library versions specified in that threatens to grow yes, but I admit I like simple solutions. I see no reason to have what appears to me to be an extra complication of another file, and an import mechanism. The android/build.gradle file is not very large, it is already under edit sometimes, it is known, and the ext{} block is pretty easy to handle. So I'd just keep it there. What naming convention if we need to specify versions? I'd love to have a naming convention though. I propose just using lower-case-first / camel-case / +Version for names. So if you needed the androidx.appcompat:appcompat dependency, you'd specify appcompatVersion. For androidx.vectordrawable, you'd specify vectordrawableVersion etc. Maybe this sucks? The important thing is to agree :-), propose something better as a convention formula and we can go with it. Can we centralize the gradle versions? I also like the idea of the gradle plugin version itself specified. I hate building my project on a new machine where it downloads 10 different gradle versions. For truly poorly maintained repos, the solution is to not use the repo. That's harsh but it's open source. Fork the thing and maintain it. Alternatively use patch-package, or don't use it. But even well-maintained packages skew between patch versions of gradle and harmony would be nice. So I'd like to see a gradle version specified in a single location if possible as well. |
I also like to keep them just in gradle file, my idea is changed because of what @matt-oakes said in this comment |
Hello guys, this is my proposal https://github.com/proyecto26/react-native-inappbrowser/pull/97/files#diff-7ae5a9093507568eabbf35c3b0665732 So we can have a configuration like this from our projects:
Let me know what you think 👍 |
Thank you for your contributions and this is my opinion about your proposal. |
I've added this to the other PR, but I thought it best to post here too. I still think having dynamic versions in the library and letting Gradle resolve them as needed is the best solution. I get that non-determinism is an issue, but why not use the same tactic as Yarn and NPM and enable locking? Documentation for Gradle dependency locking is here: https://docs.gradle.org/current/userguide/dependency_locking.html |
I could see that working technically So there would be a new file with state https://docs.gradle.org/current/userguide/dependency_locking.html#lock_state_location_and_format ...requiring folks to manage that after adding locking directives to the gradles. I'm not excited about externalizing state personally but that's clearly a solution many like via social proof of package-lock/yarn-lock/Podfile.lock and as dependencies chain I can see why I have not experienced anyone using this in pure native Android land (maybe it's just new to me though?) so I'm curious if culturally and documentation wise we'd be breaking trail. Would this still handle the case where you could work with either version 28 of support or e.g. 1.0.x of some androidx lib? And maybe need to substitute the name? Or is this just a clean androidx future? |
Hey guys, check an example of the new installation steps from the last version of my plugin https://github.com/proyecto26/react-native-inappbrowser#mostly-automatic-installation |
For the Android Gradle Plugin issue, @dulmandakh has a different solution. he proposed his solution with a few PRs in the repositories below that can be used as samples to other maintainers to change their libraries. @brodybits, please take a look at those PRs, if you find them useful, maybe it's better to start changing your template. |
from generated code in order to avoid multiple Android build tools Gradle plugin versions in React Native projects as discussed in react-native-community/discussions-and-proposals#151
from the generated code in `android/build.gradle` in order to avoid multiple Android build tools Gradle plugin versions in React Native projects as discussed in react-native-community/discussions-and-proposals#151
To keep this discussion up to date @friederbluemle has another amazing solution for the gradle plugin version issue that is much simpler than @dulmandakh's approach, you can read his idea from this comment |
which is on the PR in facebook/react-native#25569 but I think should have been here instead:
|
and quoting some more comments from facebook/react-native#25569 that I think should have been here instead: by @friederbluemle in facebook/react-native#25569 (comment) (with extra blank lines added to improve readability a little):
by @friederbluemle in facebook/react-native#25569 (comment) (with a blank line added for the sake of readability):
by @friederbluemle in facebook/react-native#25569 (comment):
another comment by @mikehardy in facebook/react-native#25569 (comment):
|
Thanks @SaeedZhiany for keeping this up-to-date. For reference, here are four PRs with the alternate zoontek/react-native-localize#69 Since this satisfies the core problem (unnecessary downloads of/conflicts with different Android Gradle plugin distributions), would you be OK with closing this issue, as well as the related issue/pr over on https://github.com/facebook/react-native/
We can still work on temporary local script to remove the |
Also thanks @brodybits for more references 👍 |
+1 for closing outdated and unwanted PRs such as facebook/react-native#25569 and closed PR in brodycj/create-react-native-module#129 -1 for closing discussions such as this one which I still think need some more work and maybe further consideration from the people involved, including myself I do think this discussion was started with too many things combined. I think the androidx version thing should have been in a separate discussion. |
Agreed, splitting it into more focussed discussions would be best 👍 |
@friederbluemle
Why? we can keep this issue opened and add more ideas whenever we found a new one. because the only problem remains in this issue is the AndroidX package management and it can be considered as a new issue thread. Although I don't see any need, If all of you agreed we can open a new one. |
However, we need to
by these, I agree with splitting androidX issue into a sperate discussion. Is it necessary to split 1) and 2) too? |
(separate discussion) +1, I think we have agreement now
I think that would make sense. TBD I am not so sure that I fully understand the points in "2)". |
then I'll open a new discussion about AndroidX as soon as I can.
It's an idea from this comment. for modules that do not apply @friederbluemle approach, we think it would great if we write a local script that can search |
A script that modifies locally downloaded dependencies in |
@friederbluemle can you do us a favor and open a new issue that describes the solution you proposed in facebook/react-native#25569 (comment), maybe with some clarification, and nothing else? I think this could really help us understand what is going on in the fix you proposed in brodycj/create-react-native-module#135, among many other places, and enable people to ask questions and understand it without the surrounding noise. The Gradle stuff is quite new for me and I suspect it would be new for a number of other people. Yes I did hear of autolink, still don't understand it so well. I guess a workaround script could help us with a short-term problem, don't have a clue how it would work. Doesn't sound like such a stable solution. |
I'm happy that we found the solution to a very common issue across RN module ecosystem. Now we need to work to spread the solution. I don't think that AndroidX version sharing is solvable because each and every package has it's own versions, unlike Android Support Library. See facebook/react-native#26481, I'm trying to upgrade AppCompat version to 1.1.0. |
Ok, then, we can put the script file in the blog that users just copy and paste in their project and use it. |
the script is going to do the same work that @friederbluemle proposed but just on locally installed dependencies in |
@SaeedZhiany do it like jetifier - make a node module that does the work, document it well, and release it. If it is useful it gets traction, and if it is really useful then after it is stabilized it might be called by react-native cli either as an option or default. Growing a tool on the side like that gives it time to settle (jetifier took 19 releases, FWIW, and that was with a test suite operating on a fair chunk of popular modules - even though it was doing something entirely proven already in other tools with an existing mapping file :-), so that settling period is more important than it seems) |
yeah, we know about that and it has already a solution but some of us like @matt-oakes seems doesn't like the idea. I don't want to continue the discussion about androidX here and I'll open a new one for that as soon as I can. but you can read about that idea by reading a few first comments in this issue and also this issue |
@mikehardy it just a simple script with at most 40 lines of code, I just didn't sure if it's worth to create a repository for it or not. but it's a good idea, we can create a simple repo for it and reference it within the blog. I insist on writing the blog because it has more chance to hit more audiences. it can help us to spread the solution with more speed. |
I don't like the idea of dependency locking, because developers have to create a new lock file every time they install/update/delete NPM packages. Or we must make it invisible, or so simple. |
It's just one of the ideas, another solution is hardcode all androidX packages versions into main project gradle file, then all module maintainers should read their required versions from the main project, just like I believe this issue is solvable too and it just needs some more times to find a good solution that satisfies everyone. |
Unlike supportLibVersion, there is no single AndroidX version, but each AndroidX package has its own version. So maintaining versions for AndroidX packages in app template in RN core is not feasible. If a package depends on appcompat, it can safely remove it because it's already provided by RN. Hard coding versions in main project gradle file might cause issues in case of package updates. For example, NPM package X requires AndroidX package of Y version of Z, and in the future maintainer wants to use newer version of package Y which has a new API, so a user of NPM package X must update NPM package, but also bump package Y version in main gradle to build it. Instead package maintainers must use an AndroidX package with a version, and gradle will use latest safe version of it if used by multiple packages. For example, package A requires appcompat version 1.0, and package B requires appcompat version 1.1, then gradle will automatically use only version 1.1. |
@SaeedZhiany jetifier started with less than 40 lines of code (and still worked! except all the tiny corner cases we discovered later, and performance, and...) :-) - a good tool deserves it's own repo, IMHO. I personally don't mind having an ext{} block in my /android/build.gradle file at all 🤷♂ - it lets me pin my android dependencies pretty much right where I'd expect, in a file I have to have anyway |
yeah, we discussed about it before and we know about that.
it just causes having a big template file, I don't see any other problem that causes infeasibility.
I didn't get this statement. what do you mean?
Are you mean Gradle automatically downloads only the latest versions of androidX packages required? or downloads all versions used among all npm packages and only uses the latest version? I think having the versions in the project's Gradle file forces the sub-modules maintainers to keep their code up-to-date whether directy by themself of indirectly by sub-modules users (by creating PR on that sub-modules repository) and this is very good. |
side note: I'm on a short trip and I don't have access to my laptop, so typing with mobile is hard for me. can anyone create a new issue for androidX discussion and move all androidX related comment to the new issue, please? |
Then I'll create a repo for it as soon as possible. :) |
This is the outcome of a react-native-community discussion with the goal of avoiding downloading multiple gradle versions and/or loading multiple versions at the same time react-native-community/discussions-and-proposals#151 (comment)
This is the outcome of a react-native-community discussion with the goal of avoiding downloading multiple gradle versions and/or loading multiple versions at the same time react-native-community/discussions-and-proposals#151 (comment)
This is the outcome of a react-native-community discussion with the goal of avoiding downloading multiple gradle versions and/or loading multiple versions at the same time react-native-community/discussions-and-proposals#151 (comment)
This is the outcome of a react-native-community discussion with the goal of avoiding downloading multiple gradle versions and/or loading multiple versions at the same time react-native-community/discussions-and-proposals#151 (comment)
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Introduction
Hi, everybody,
I come from a discussion from here.
The discussion briefly is about how we should handle the version of androidX packages used by RN libraries from main project gradle file in a consistency way.
The Core of It
The main problem before RN 0.60.x is that RN library developers using his/her preferred gradle plugin version within their libraries without any attention to main project gradle plugin version. also, due to inactivity of its maintainer, there are lots of RN libraries that not using latest gradle plugin and even sending PR to upgrade the version doesn't help due to lack of PR reviews by the maintainers. so it causes some sort of problems in building android project due to multiple gradle plugin version used in the process. so CI servers usually fail in the building (and in my case, I can't automate my release building)
some workaround for the issue (that I currently use it) is writing a script that reads main project's gradle plugin version and replaces the versions in the libraries' gradle files to make all the libraries compatible with the main project. to be honest I don't like such patchy works. I like to solve problems from their root.
Recently, androidX support has been added to RN and library developers has begun to migrate their libraries to using androidX instead of support libraries. react-native doesn't include androidX packages' version into gradle file, so I think the second wave of nightmares(!!!) will come shortly.
Each developer has own strategy to migrate.
Some of them use a fix version number just like to gradle plugin version and obviously, it has
the same problem as a result.
The others assume that an extra property is defined in project-level gradle with a name that their library is using.
although this is a better way compared to the first one, it has another problem. due to the lacking naming convention, every developer can assume their pattern for the name of androidX packages within
ext
. as an example for androidX's annotation package, developer A assumes an extra property with the nameandroidXAnnotation
and developer B can assumeandroidX_annotation
and so on.)So I start this discussion to make a general solution that avoids patchy workarounds and solve the mentioned issues in a more precise way.
solution for gradle plugin version
I currently submit a PR for android gradle plugin issue here but unfortunately, it does not even receive a precise review yet, only one opposition that can not convince me why my proposed solution isn't correct.
solution for androidX package's version
This is just an idea in my mind from discussing with @mikehardy, @matt-oakes, and @jdnichollsc, (it's would so good if you take a time to read the discussion)
I know androidX packages are separately maintained and have their versioning scheme that is not necessarily the same among the packages so having lots of properties within the main project gradle file seems not a good solution.
So I'm thinking about having a separated RN project-level file in for specifying the packages' version, then somehow importing them in project-level gradle as extra properties using gradle commands. I don't much familiar with gradle system and groovy language so I couldn't submit a PR for that. is anybody can confirm if is it possible to do such thing at all? and if yes, how we can achieve that.
Discussion points
I like to reach a naming convention about androidX packages so RN library developers can rely on that to import and use the packages' version in their libraries in a consistent way with the other libs used in an RN project.
Also, Finding a solution to make RN libraries automatically use project-level gradle plugin version.
The sooner the better, because I think the more time passes, the harder it becomes to solve these problems.
The text was updated successfully, but these errors were encountered: