Skip to content

Instantly share code, notes, and snippets.

@choyan
Last active May 28, 2021 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choyan/e92509e80bec796dfc287458e04ace8a to your computer and use it in GitHub Desktop.
Save choyan/e92509e80bec796dfc287458e04ace8a to your computer and use it in GitHub Desktop.

Installation Procedure

Need to have Node and JDK installed.

For JDK

sudo apt install openjdk-8-jdk

Download and install Android Studio https://developer.android.com/studio/index.html

SDK Manager

The SDK Manager can be accessed from the "Welcome to Android Studio" screen. Click on "Configure", then select "SDK Manager". Select the "SDK Platforms" tab from within the SDK Manager, then check the box next to "Show Package Details" in the bottom right corner. Look for and expand the Android 9 (Pie) entry, then make sure the following items are checked:

Android SDK Platform 28 Intel x86 Atom_64 System Image or Google APIs Intel x86 Atom System Image

Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that 28.0.3 is selected.

Finally, click "Apply" to download and install the Android SDK and related build tools.

Add the following lines to your $HOME/.bash_profile or $HOME/.bashrc config file:

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

##Creating a new application npx react-native init AwesomeProject

##Using a virtual device If you use Android Studio to open ./AwesomeProject/android, you can see the list of available Android Virtual Devices (AVDs) by opening the "AVD Manager" from within Android Studio. Look for an icon that looks like this:

Android Studio AVD Manager

If you have just installed Android Studio, you will likely need to create a new AVD. Select "Create Virtual Device...", then pick any Phone from the list and click "Next", then select the Pie API Level 28 image.

##KVM acceleration https://developer.android.com/studio/run/emulator-acceleration.html#vm-linux

sudo apt install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils ia32-libs-multiarch sudo apt install qemu qemu-kvm virt-manager

##Running your React Native application react-native run-android

Modifying your app Now that you have successfully run the app, let's modify it.

Open App.js in your text editor of choice and edit some lines. Press the R key twice or select Reload from the Developer Menu (Ctrl + M) to see your changes!

Auto Reload

On the device use the shortcut ctrl+m. Enable Hot Reload and Live Reload

React Native on VSCode

https://github.com/microsoft/vscode-react-native

Run React-native

In one terminal

run-emu

In another terminal

npx react-native start

In another terminal

npx react-native run-android

Build apk

First create assets folder inside android/app/src/main/ Then run

npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

Then go inside android folder and run

./gradlew assembleDebug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment