I used windows 10 as my development environment in this tutorial.
Pre-requisites:
- Download Android-sdk-tools from https://dl.google.com/android/android-sdk_r24.4.1-windows.zip OR use windows installer https://dl.google.com/android/installer_r24.4.1-windows.exe ( I used zip archive )
- Install Nodejs v12 or later
- Install Java JDK 8
- Install React Native and setup develop environment (here is the official documentation, which is straight forward https://reactnative.dev/docs/getting-started )
- You can use either React-Native-CLI, or Expo CLI as mentioned in https://reactnative.dev/docs/environment-setup
- I am going to use https://github.com/Starotitorov/tic-tac-toe for this demonstration, you can clone that repository..
I used the 'Android-SDK-tools' zip archive, and extracted in a folder in 'C:\' drive.
Then add these items to 'system variable'.
ANDROID_HOME : 'Android-SDK-tools' zip extracted location
ANDROID_SDK_ROOT : 'Android-SDK-tools' zip extracted location
Now edit PATH variable, add (append) path to 'platform-tools' folder as below
After that open a new 'powershell window' and make sure`java`, `javac`, `adb` commands are working.
Now open SDK manager and download required SDK packages. I used https://github.com/Starotitorov/tic-tac-toe to this demonstration.
Now you can see the codebase for our 'tictactoe' app, and we need to run it in android environment. I used an actual device, which is enabled the USB debugging, since it was hard to run an emulator in my machine.
- Run `npm install`
- Run `npx react-native run-android`
It is good to use `npx react-native run-android warning-mode=all` to get a detailed description of the app debugging status.
Did you get any errors when running the Android application? Check this post for the FAQ related with running react-native application. This contains answers for the following problems,
- Keystore file '/<project-folder>/android/app/debug.keystore' not found for signing config 'debug'
- Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory
- Emulator or device not found error
No comments:
Post a Comment