Running React Native App on Android from Windows or Linux

I was at Hack Night Session and trying to run React Native Hello World App on my friend’s Android Device. Installation of React Native modules are simple. First you will need to install Nodejs and Python2 on your PC as said in React Native documents. So after running below command you will have React Native Client installed.

As instruction say you will need to download Android SDK (installing JDK before would be nice) and make sure have Android Build version 23.0.1 installed. If not can do this from AVD.

After all requirements are installed, instruction say to run below commands.

If you run it on Android Device you probably will get below error.

adb reverse tcp:8081 tcp:8081 error closed

In the React Native documents, it say to execute below command for android device to connect to Packager server (React Native Debug Server).

Unfortunately this will only work with android version 5.0+ so if you try this below v5.0 will get error from adb. Below is the step I took to start the android app from windows 10.

Run command line as administrator and start the Packager. (Make sure you are on the project directory.)

On the different command line go to your project directory and execute below command.

If you get error, probably need to create the directory for copying the file from the Packager.

Run the curl command again and should be able to download the file from running Packager. After the download, run the build command for React Native App.

Next thing you will encounter is error message stating app could not connect to development server from application screen. Since the android device is not connect by adb reverse, it can not see the debug server running on your local PC (http://localhost:8081). At this point you should have http://localhost:8081/debugger-ui open on your browser and have dev tool console line open to check if there are connection.

From here follow the document about connecting to development server via wifi. After the setup, from the development menu on your app, select Debug JS Remotely and you should see the connection success on browser dev tool console. Always make sure PC and android device are on same wifi network (same SSID).

This is just a not when working inside native android code. When running build command will encounter build error many times, but turning off the Packager during the build process and on again when app is installed works (I assume it is not a best way but it just does somehow).

 

 

 

 

Leave a Reply

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

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.