Convert ReactJS App to Android App on Ubuntu

Install Cordova

npm install cordova -g

Create a Cordova project

cordova create ReactBasedPhoneApp

Open package.json of the existing ReactJS App.
Copy the sections – scripts, dependencies, browserList from the above package.json and paste it into the ReactBasedPhoneApp/package.json

Build the existing ReactJS App

npm run build

After the build completes successfully, copy the contents inside the build folder of the existing reactJS app to ReactBasedPhoneApp/www folder

Set Android Home

export ANDROID_SDK_ROOT=/home/{username}/Android/Sdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Add Android plugin

cordova platform add android

#in case you use phone camera in the application
cordova plugin add cordova-plugin-camera

Build the APK

cordova build android

#if you want to debug the app in a running simulator or USB connected android phone
cordova run android

Sreekumar Kj
Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics. He now runs a conversational AI company - DheeYantra - focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.

Leave a Comment

Your email address will not be published. Required fields are marked *