Before running a ReactNative project
A checklist for things you should do before you run a ReactNative project.
1. Setup Android SDK location in your local.properties
Create a file named “local.properties” at the root of your project folder, and insert the following (if file already exists, check if the line exists, or else just add it in the next line):
$ sdk.dir = /Users/USERNAME/Library/Android/sdk
Remember to include local.properties into .gitignore so that it doesn’t get included in the source.
2. Install the dependencies
$ npm install
3. Link assets to project
Run the following code:
$ react-native link
For iOS deployment:
$ cd ios && pod install && cd ..
4. Sync Gradle
Open AndroidStudio, and select “Open an existing Android Studio project”. Navigate to the /android directory of your RN project and click “Open”.
Give it a few seconds and you should see a message, “Gradle sync started” on the event log at the bottom left of your window.
Wait until it says “Gradle sync completed” before moving on to the next step.
5. Running the app on your device/simulator
$ react-native run-ios
$ react-native run-android
Extra: Cleaning the project’s tasks for Android
If for some reason you have trouble running the app on Android after successfully running it the first few times, you can try cleaning up the project’s tasks by running:
$ cd android && ./gradlew clean && cd ..
When it’s done cleaning up, try running step 5 again.
- Every time you notice a message like: “Deprecated Gradle features were used in this build, making it incompatible with Gradle X.X.”, just follow through with Step 4: Sync Gradle.
- You should try Flutter out if you’d like to reduce a great deals of these hassles of developing cross platform on ReactNative. 😉