healthhackersER / CAMA-CORE-Example

4 stars 1 forks source link

[SETUP] Testing the app on a virtual device #34

Open IvoLeist opened 4 years ago

IvoLeist commented 4 years ago

Problem

Android Studio is the tool of choice if you want to test the app on a virtual device. However, it is quite Ram heavy https://miro.medium.com/max/999/1*9mP8ScTFbvC_8Eb_Hjsl0w.jpeg

Solution

Find a better way to start a virtual device

Found: Genymotion

Goal

Save a lot of space and enable developers to test the app on a virtual device w/o worrying too much over the RAM usage

IvoLeist commented 4 years ago

I found that tutorial on medium: https://medium.com/@rishii.kumar.chawda/install-android-emulator-for-react-native-app-without-installing-android-studio-727d7734528

However, I did not manage to make it work...

System: Windows10 Home Build:19041.21 (Insider Slow Rig)

What I tried so far: Setting up a WSL (Windows Subsystem for Linux) with Arch Linux installed Android SDK + Genymotion (https://www.genymotion.com/) But ended up with some virtual device not able to start error -> Gave up after playing around with several versions of the SDK

Upgraded my Arch Linux WSL to WSL2 (Win10 insider slow rig required) -> A new Error, progress (?). Googled a bit but came to the conclusion that the WSL Kernel does not seem to support virtual devices?

GundlackFelixDEV commented 4 years ago

Is connecting your physical device via USB an alternative? Because this works quite well using expo.

@see Documentation

Here is a tutorial: https://medium.com/@psyanite/how-to-connect-expo-to-usb-android-device-16b83ff67428

IvoLeist commented 4 years ago

@GundlackFelixDEV I have not tried that yet. But even if so with this issue I want to find a solution for testing the app on a virtual device. For the record opening on my device connected via USB works flawless

IvoLeist commented 4 years ago

Finally managed to run Genymotion (on Manjaro)

Biggest issue was to find a tutorial which was up to date. Some years ago you apparently were forced to install Android-Studio (android-sdk) Took me quite some time to realise that this is not the case any longer

So here is my install workflow (for Manjaro) yay -S Genymotion During the install you are asked to modify the virtualbox conf file DO IT REBOOT Open genymotion (from terminal) create a new virtual device + launch cd into the CAMA-CORE-Example folder expo start (npm run) somehow does not work open a browser and go to http://localhost:19002/ Click on "Run on Android/Emulator"

*! If there is an adb reverse error 1.Check what happens if you execute adb in the terminal 2.Test a newer device (https://stackoverflow.com/questions/31525431/getting-error-closed-twice-on-adb-reverse)

Screenshot_2020-03-01_15-06-32

IvoLeist commented 4 years ago

Had some success regarding running the virtual device on a docker container :)

After wild googling (android + emulator + docker) I ended up here: https://github.com/softsam/docker-android-emulator

Run the docker container with docker run -d --name android softsam/android-21 *The versions below 21 do not work because of this error https://stackoverflow.com/questions/31525431/getting-error-closed-twice-on-adb-reverse

Make sure that the container is up and running with docker ps

Got the IP address of my container with: IP=docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' android

Connected to the container with adb connect $IP

Double checked if connected with adb devices

Navigated into CAMA-CORE-Example and executed expo start

Waited for AGES for the completion of "Installing Expo on device..."

Till "Running application on sdk_phone_armv7"

Success ? Now I have the emulator up and running but do not see it xD `

IvoLeist commented 4 years ago

Could not sleep before I solve that problem :D

intensified wild googling (android + emulator + docker + x11) got me that: https://github.com/pinfake/android-emulator-x11

git clone the repo and switch the branch to your linux distro git checkout archlinux-25

run the container: docker-compose up -d -> Android Emulator pops up

Navigate into CAMA-CORE-Example and execute expo start

Installing Expo on device... -->DONE