Last active
February 17, 2020 14:15
-
-
Save sanchocreativo/fe13dffe35800169271f207501d08b20 to your computer and use it in GitHub Desktop.
Running React Native Projects from scratch on Ubuntu 18.04 via Usb Device on Android (Could work for other Distros) for the ones who comes from React web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| It could be tricky if you are coming from React for web and switching for React Native and thinking it could be an easy thing. | |
| It has some workarounds and for making it work it may differ depending on the android device plugged by usb. | |
| Setting the correct environment for your Android. | |
| 1. Enable debugging mode for USb. This is usually on Other Settings or Aditional Settings > Developer Options. Don't | |
| close this windows for step 2. | |
| 2. On developer options switch ON the switch that goes by the name "Verifiy applications by USB". This allows your | |
| computer to manage and update the app from your linux pc. | |
| Setting the correct environment for Linux. | |
| 1. Install Android Studio. (Install Java if you haven't) | |
| sudo snap install --classic android-studio | |
| 2. Open Android Studio | |
| Go to File->Other Settings->Default Project Structure/JDK Location: | |
| and copy what ever string is specified there. | |
| 3. Open terminal then, export JAVA_HOME=/snap/android-studio/82/android-studio/jre or you paste what you got on Androi Studio. | |
| 3.i. Accept SDK Licenses : Paste in terminal: $ > yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses^C | |
| 4. Open your project or create a new one $ > npm install -g react-native-cli | |
| 5. > react-native init <project name> | |
| 6. In the terminal > adb devices. If not install | |
| sudo add-apt-repository ppa:nilarimogard/webupd8 | |
| sudo apt-get update | |
| sudo apt-get install android-tools-adb android-tools-fastboot | |
| 7. Open your react native project folder. Open Android folder. Create a new file called. local.properties | |
| Inside the file write this: | |
| sdk.dir = /home/{inuxpcName}/Android/sdk | |
| 8. Copy your device id. | |
| 9. Run your react native project. react-native start <Your project name>. | |
| 10. Run your usb app live. react-native run-android --deviceId xxxxxxxxxxxxx (paste your device id in the x's) | |
| Sometimes you don't need your device id but this solves some issues I've got. | |
| Let me know if this works if you tried it! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment