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
Package AAR file #255
base: master
Are you sure you want to change the base?
Package AAR file #255
Conversation
is this a breaking change? can u upgrade example as well? |
Hey, I have a couple of questions to better understand this pull request:
I see no code here that would make Do you think you could use a |
It shouldn't break anything since I didn't touch the source code of the lib.
Will do
Didn't know about that, will add it, thanks :)
I can try that, didn't know about postlink, thanks :) |
Hey @grabbou @sibelius, I'm back! Sorry it took so long to get back to you, I've had some other priorities at work and this got delayed. I'm also moving the issue discussion here so we have only one thread to focus on. I've been trying to experiment a bit with
Solution to Solution to Any idea on what would be the next step? |
Hey @fourlastor! I don't feel comfortable merging Android PRs, since I'm not really qualified in this area, but is there any prior art as far as AAR packages go in react-native world? I don't think I've seen an RN native module published this way before |
@radex react native itself is shipped as an AAR library, instead of having the source code in the NPM package. |
The current approach has its advantages. In several projects, we use patch-package to patch the module when we have compatibility issues or fixes that are not merged into the module. Shipping pre-compiled binary will make it much harder. |
can't we have both approach? precompiled and enabling patching code as well? |
This PR introduces pre-packaging of the Android lib in as an AAR archive, as per #239.
This solves a bunch of problems with the current approach, as described in the issue (Android Studio failing to compile from time to time, different build tools version between client and library and compilation time).
I added a dev dependency to react-native, but the library is packaged with a
provide
directive so it won't include react-native in the artifact, it's still required to compile the library.The lib version is parsed from
package.json
and to compile the lib you can invoke./gradlew generateReactArchive
.What's left to do is to include the artifact inside the published npm library, for which I don't know the process, happy to add more stuff if someone can point me in the right direction :)
The only doubt I had was with the
react-native link
command, but I tried and it seems like it won't add it to the project, so that should be fine. Ideally there would be a way to customise what link adds to the project on a per-library basis. This also means this PR impliesreact-native link
won't work anymore for Android.Also, I think this should remove the need to specify the build tools version with an ext variable as this won't create problems anymore.