|
|
|
## Setting up Mobile Development Environment
|
|
|
|
|
|
|
|
[Mobile Repository](https://gitlab.labranet.jamk.fi/wimma-lab-2019/overflow/ehasa-mobile)
|
|
|
|
|
|
|
|
You need node installed as specified in [1.2 Node.js - installation](./node)
|
|
|
|
|
|
|
|
First, install npm module react-native-cli:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install -g react-native-cli
|
|
|
|
```
|
|
|
|
|
|
|
|
Second step is to get Android Studio to run.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo apt-get install openjdk-8-jdk -y &&
|
|
|
|
wget https://dl.google.com/dl/android/studio/ide-zips/3.4.2.0/android-studio-ide-183.5692245-linux.tar.gz &&
|
|
|
|
tar xzfv android-studio-ide-183.5692245-linux.tar.gz &&
|
|
|
|
~./android-studio/bin/studio.sh
|
|
|
|
```
|
|
|
|
|
|
|
|
When asked for installation type choose `custom`
|
|
|
|
|
|
|
|
Make sure the following checkboxes are checked:
|
|
|
|
|
|
|
|
- Android SDK
|
|
|
|
|
|
|
|
- Android SDK Platform
|
|
|
|
|
|
|
|
- Android Virtual Device
|
|
|
|
|
|
|
|
Android Studio installs the latest Android SDK by default. Building a React Native app with native code, however, requires the Android 9 (Pie) SDK in particular. Additional Android SDKs can be installed through the SDK Manager in Android Studio.
|
|
|
|
|
|
|
|
The SDK Manager can be accessed from the "Welcome to Android Studio" screen. Click on "Configure", then select "SDK Manager".
|
|
|
|
|
|
|
|
The SDK Manager can also be found within the Android Studio "Preferences" dialog, under Appearance & Behavior → System Settings → Android SDK.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
You need to install kvm to emulate the android phones, and add your current user to the kvm group
|
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo apt-get install qemu-kvm
|
|
|
|
sudo adduser $USER kvm
|
|
|
|
```
|
|
|
|
|
|
|
|
Relogin to load the changes.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo "
|
|
|
|
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
|
|
|
|
" >> ~/.bashrc &&
|
|
|
|
source ~/bashrc
|
|
|
|
```
|
|
|
|
|
|
|
|
Inside the mobile repository:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo "sdk.dir = /home/\$USER/Android/Sdk" > android/local.properties &&
|
|
|
|
npm i &&
|
|
|
|
sudo react-native run-android
|
|
|
|
``` |