-
Notifications
You must be signed in to change notification settings - Fork 441
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
Update and fix Gradle setup #384
Update and fix Gradle setup #384
Conversation
13f02a6
to
6694f68
Compare
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion safeExtGet('compileSdkVersion', 27) | ||
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.2') | ||
|
||
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not needed anymore, so it's better to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct, with more recent versions of the Android Gradle plugin this is no longer required - However: At some point (about a year ago), adding this would actually cause a warning in the build log. Also Android Studio templates did not have this line anymore. Then something changed: After another update, the line was added again in the Android Studio template (it's even still present in the latest stable version 3.5.0). There is also no more warning, as far as I can tell. Do you happen to know more details by any chance?
Also - Since the version of the Android Gradle plugin is not determined by the library project, but by the app project, there is a chance that the app still uses an older version that requires this line (although today this chance is very low, or even non existent). Removing it could break it, while keeping it there can do no harm (other than possibly a warning). Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Play Store requires 64bit support, so developers must use at least RN 0.59. And to have proper AndroidX support, developers use RN 0.60. So there is a zero chance to an app will use older version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. But do you know what's the reason this was reverted in the official template (i.e. the line reappeared, and it's no longer a warning)?
Also, I think that we should have gradle wrapper since it maybe be used as a root project. |
Hi @dulmandakh and @friederbluemle - thanks so much, and I apologise for the delay in getting back you you. I've looked at both implementations and I'm tempted to go with this one. Are you both in agreement with this or is there more to be done in your opinion @dulmandakh ? |
68b3f15
to
b1ac61c
Compare
Hi @kadikraman - Thanks for the review! 👍 |
"android", | ||
"index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add these files back, please? In particular, removing the index.js
would break deploying new versions (since only the files listed here will get pushed to npm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.js
is set as main
in package.json
. Just like a bunch of other files, it is always included in the packed version, and there no need to manually specify it. You can just do a quick npm pack --dry-run
locally to see that it is included even though it's not in the files list.
package.json
Outdated
"react": "^16.1.1", | ||
"react-native": "^0.50.3" | ||
"react": "16.8.6", | ||
"react-native": "0.60.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any major breaking changes between 60.3, 60.2 and 60.1? If not, I'd prefer this to be ^0.60
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no major breaking changes that I know of (in the versions you mentioned). However, there no way to guarantee that. The reason I chose 0.60.3
here is to align it with the example project (we can update it independently in a separate PR). The problem with using ^0.60
here is that RN does not strictly follow semver (yet?). ^
fixes the major version only, so it would happily update it to 0.61.* (or 0.62.x once release etc). And those version might contain breaking changes (as well as accidentally become out-of-sync with a matching react
version).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to fix the failing CI (with the updated and fixed RN version), I also had to update and align a couple of other files/devDependencies (fixing the jest test runner). Please let me know if you prefer these changes to be done separately (as a prerequisite to this PR).
b1ac61c
to
d51fe72
Compare
d51fe72
to
f922518
Compare
Hi @kadikraman - Just a friendly reminder to please take another quick look at these changes and merge if everything is clear. I rebased the branch again onto the latest |
f922518
to
b2f8cc1
Compare
Updated to the latest Android Gradle plugin |
b2f8cc1
to
cbe650c
Compare
Rebased and resolved conflicts. |
Hi @friederbluemle thanks for everything - could you please merge in the latest master (or give me push access to your fork, I've done it locally before realising I couldn't push 🤦♀ ) Hoping to get this merged this week. |
Hi @kadikraman - Thanks for getting back here, and happy new year! I've rebased the branch and resolved the conflicts. One of the three commits ( To fix the following compile error, I had to update the default
The project now builds without issues both on command line and in Android Studio. Both |
cbe650c
to
f67ce6a
Compare
Released in v5.0.0 🎉 |
Description
Android Gradle plugin
This wraps the Android Gradle plugin dependency in
buildscripts
section inandroid/build.gradle
in a conditional:A small change with a big impact:
The Android Gradle plugin is only required when opening the project stand-alone, not when it is included as a dependency. By doing this, the project opens correctly in Android Studio, and it can also be consumed as a native module dependency from an application project without affecting the app project (avoiding unnecessary downloads/conflicts/etc).
Please see related discussion in #381 - This PR replaces and closes #381.
Gradle wrapper
Similarly the Gradle wrapper (and related scripts) are only required for stand-alone editing/building of the
android
folder. It should not be distributed. Android Studio will automatically generate a wrapper, or alternatively one can be generated on the command line on-the-fly (see below).Missing dependency
The
dependencies
section was missing a reference toandroidx.browser:browser:1.0.0
, causing a compile error inRNAppAuthModule
.Missing Android debug keystore in example
Due to an oversight, the
debug.keystore
file was ignored - This is already fixed on react-native'smaster
branch: https://github.com/facebook/react-native/blob/master/template/_gitignore#L43I re-added the keystore to fix the build error in the
AndroidExample
project..npmignore config
In a separate commit, this PR also includes a small update to the npmignore config of the project. By excluding the Gradle wrapper jar and scripts a significant size reduction of the distribution artifact to less than a third of the previous value was achieved:
Before:
After:
Steps to verify
What's required for testing (prerequisites)?
Android Studio and/or Gradle installed locally.
What are the steps to reproduce (after prerequisites)?
Open
android
in Android Studio:Or:
Generate a Gradle wrapper on the fly, and build on command line:
cd android/ gradle wrapper --gradle-version 5.4.1 --distribution-type all ./gradlew build
Successfully verified and tested on:
Once approved, please use a normal GitHub merge (i.e. NO rebase/squash merge) to integrate the commit(s) from the PR head branch. The changes are broken up into meaningful, atomic commits, and my branch should already be up-to-date with the latest base branch. If it isn't, or if you want me to change anything, please let me know, and I will update the branch as soon as possible. Thank you!