Skip to content

Add gradle plugin and androidX versions into project-level gradle #151

@SaeedZhiany

Description

@SaeedZhiany

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.

  1. Some of them use a fix version number just like to gradle plugin version and obviously, it has
    the same problem as a result.

  2. 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 name androidXAnnotation and developer B can assume androidX_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🗣 DiscussionThis label identifies an ongoing discussion on a subject

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions