*_jemarea_*

Website Development

  • Home
  • Articles
    • All articles
    • Linux
    • WordPress
    • Codeigniter
    • PHP
    • JavaScript
    • MySql
  • About
  • Contact

July 9, 2018 By jerome Leave a Comment

Run React Native on Android Mobile

In a previous post I explained how to set up Android Studio and get React Native run on the emulator.

This time we are going to set up the environment step by step to run the App on our real android device.

1) You should have your React Native App already set up on your computer

2) Prepare your Mobile

Before connecting your mobile via USB to your computer do the follwing steps:

  • If your mobile is not yet set for developers (you would know), go to
    Settings > General > About phone (or just About) > Hardware Info (if you don’t have “Hardware info” you might already see ‘Build number’
  • Tap 7 times on “Build Number” (or on “Hardware Number” if Build Number not there)
    -> this will set your Mobile to Developer Mode
  • Go to Settings > General > Developer Options and activate “USB debbuging”
  • Now on your computer (phone still not connected!) open a terminal and type (without the dollar sign):
    $ lsusbThis will return a list of devices connected to your machine. Keep this terminal window open.

3) Connect your phone to your computer

Good, now connect your phone to your computer via USB.

Again, type lsusb and look at the output. You should have 1 line more than before. From this line, we need the 2 numbers that might look something like this:
04c8:07ab

Write the following in your terminal (don’t forget to replace the numbers with those from your output):

echo SUBSYSTEMS=="usb", ATTRS{idVendor}=="04c8", ATTRS{idProduct}=="07ab", MODE="0666" GROUP="plugdev" | sudo tee /etc/udev/rules.d/51-android-usb.rules

Now we will restart the service to read this new rule. Enter in your terminal:

$ sudo service udev restart

or

$ sudo /etc/inti.d/udev restart

(if later your phone hasn’t been recognised, you can try a reboot of your computer)

Now let’s see if your phone is “there”. In your terminal enter:

$ adb devices

If nothing there, try these 2 first:

$ adb kill-server
$ adb start-server

As mentioned above. If your phone is still not recognised, reboot your machine.

If things are still not working, try the following on your (connected) mobile:

  • Go into settings > Networks > Tethering & networks and activate “USB tethering”

4) Finally your App

Now cd into your App’s directory on your computer and run:

$ react-native run-android

… wait and your App should appear on the screen of your phone..

Filed Under: JavaScript, Linux, React, Ubuntu

Leave a Reply Cancel reply

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

Copyright © 2023 · jemarea.com