Published on 08/22/2022
Published by Pratik Takle
Steps to compile your android app using react native
Prerequisites
- Check your repository and its versions.
- Check JDK version on your system.
- Use JDK11, it is necessary to compile your app.
- Either set you JAVA_HOME to JDK11 location or install new one.
- Update you node js to latest (currently v18).
- Check your android and android sdk locations.
- To check JAVA_HOME & ANDROID_HOME (for MacOS)
-
12echo $ANDROID_HOMEecho $JAVA_HOME
-
- Check your version in
- android – build.gradle
- buildToolsVersion = “30.0.2”
- minSdkVersion = 31
- compileSdkVersion = 31
- targetSdkVersion = 31
- kotlinVersion = “1.3.72”
- classpath ‘com.android.tools.build:gradle:4.2.0’
- classpath ‘com.google.gms:google-services:4.3.13’
- android – build.gradle
- Keep your app version equal in following files
- package.json
- android/app/build.gradle
Steps to follow
- Open your react native repo in vs code.
- Open terminal/git bash for better view.
- Locate the terminal path to your project folder.
- Install the package manager to your folder.
- You can use NPM or YARN (I would suggest YARN).
- Run the following command to install the package manager.
-
1yarn install
- Check your repo and check whether node_modules is added or not.
- To upgrade react-native run following
1yarn add react react-dom - To update, lottie-react run following
1yarn add lottie-react - Now run the following command to compile your repo
-
1yarn clean
- After compiling, run the following command to prepare your app
-
1yarn install-apk
- Now run the following command to prepare a bundle file, which you need to upload to the Google console to publish your app.
-
12cd androidÂ./gradlew bundleRelease
-
For any doubts or errors, check for available tutorials at https://awxdocs.com/tutorials/android-app-building/
- If the issue still persists then drop a message in teams.
- Happy coding!