Saturday, May 2, 2020

Develop android applications with react-native, without installing android studio

As a React-Native developer it is not mandatory to use Android Studio to develop applications. And some people don't like to install Android Studio since it consumes lot of system resources. But it is must to have 'Android SDK tools' installed in our machine to build android applications. So we are going to install 'Android SDK tools' without installing 'Android Studio'.

I used windows 10 as my development environment in this tutorial.

Pre-requisites:
You can refer this post if you encounter problems during this tutorial

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`
`npx react-native run-android` it is expected to start downloading all the necessary files required for Android and Gradle, and making the app-debug.apk and install it on the device.

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