patch-react-native-android.mo
Last updated
Last updated
A React Native application
Download the NDK (it can take 20 to 30 minutes)
Once the download has started you can move on to the next steps
Copy the files that contain the fixes inside a fix-rn
directory at the root of the project
Create a scripts/fix-rn.sh
file at the root of your project, looking like:
for example:
Make the file executable by running $ chmod +x scripts/fix-rn.sh
Checks:
when you run
$ scripts/fix-rn.sh
your files have been changed in your node modules
Add scripts/fix-rn.sh
in the postInstall
of your package.json
Make sure your run yarn
after you've pulled the latest changes in your deployment script
Checks:
when you run your deploy script your files have been changed in your node modules
Add gradle-download-task as dependency in android/build.gradle
:
Add the :ReactAndroid project in android/settings.gradle
:
Modify your android/app/build.gradle
to use the :ReactAndroid project instead of the pre-compiled library, e.g. - replace compile 'com.facebook.react:react-native:+'
with compile project(':ReactAndroid')
:
If you use 3rd-party React Native modules, you need to override their dependencies so that they don't bundle the pre-compiled library. Otherwise you'll get an error while compiling - Error: more than one library with package name 'com.facebook.react'
.
You don't need to change the code of all your modules. Modify your android/app/build.gradle
, and add at the same level that dependencies
and android
:
Once the NDK has been downloaded unzip it under /Users/your_unix_name/android-ndk/
(create android-ndk
if necessary)
Set ANDROID_SDK
and ANDROID_NDK
through you local shell (.zshrc
or .bashrc
), for example:
Don't forget to run source ~/.zshrc
(or .bashrc) to get the environment variables in your current shell session
Checks:
when you run
react-native run-android
your app compiles and you can see that:ReactAndroid
is built in the logs
(This part comes from the )