Skip to content

Instantly share code, notes, and snippets.

@meisinger
Last active February 19, 2020 02:21
Show Gist options
  • Save meisinger/672447f56c78d1ac0e6ad74cd251783b to your computer and use it in GitHub Desktop.
Save meisinger/672447f56c78d1ac0e6ad74cd251783b to your computer and use it in GitHub Desktop.
Fun with Android, React-Native and Arch Linux

Install the android sdk, platform tools and build tools

yaourt -S android-sdk android-sdk-platform-tools android-sdk-build-tools

Android SDK

Was asked which JDK should be installed: opted for the default (jdk-openjdk)

No clue if this will work or not (React Native says it needs "8" and the default is "13"... I think)

Android SDK Build Tools

No worries

Android SDK Platform Tools

No worries

Install Genymotion (emulator)

yaourt -S genymotion

Genymotion will tell you need the following modules loaded:

  • vboxdrv
  • vboxnetflt
  • vboxnetadp
  • vboxpci

Little tip: vboxpci has been dropped so if you try to "modinfo" it, it will fail

Ensure the modules are loaded

modinfo vboxdrv
modinfo vboxnetflt
modinfo vboxnetadp

If not, use modprobe to start them. Otherwise, look it up.

Now is a good time to restart (because genymotion and virtualbox)

Install react-native-cli Globally

npm install -g react-native-cli

Create a directory and init a new react-native project

react-native init mobile_client

sit back and relax... this could take a while

Welcome Back

"cd" into the project directory

react-native doctor

Fix Issues: Because You Didn't Read Ahead

Selecting the "default" JDK was the wrong the choice. Stick with jdk8 (its what works)

pacman -S jdk8-openjdk
pacman -Rn jdk-openjdk

Add Android 28

Currently (as of this writing), react-native likes 28.0.3

skdmanager "platforms;android-28"
sdkmanager "build-tools;28.0.3"

I (clearly) have no idea what is happening here so... if you use an IDE or GUI, use those instead to manage the SDK packages and tools

Fire It Up

Open a separate terminal or shell in the same directory

npm start

In the original (or yet another) terminal/shell run

react-native run-android

LOL, not so fast!

Interesting... no emulators found. This is clearly different from iOS and Mac which will launch the simulator if one isn't already running. To end the suspense, it will fail because there is no simulator/emulator

Bye Bye Genymotion, Hello Emulator

Pro Tip: dump Genymotion for now (username and password for this shit?)

Just download Android SDK Emulator

sdkmanager emulator

Create an AVD

avdmanager create avd -n simple_28

This failed hard with a cryptic "No package"

So back to sdkmanager

sdkmanager "system-images;android-28;google_apis;x86"

Go and get a meal or something... this might take a long time

I am more than certain that I have done this in an obtuse manner. Perhaps there is a better (more specific) way to download a package or just a single package

avdmanager create avd -n simple_28 -k "system-images;android-28;google_apis;x86"

Start the Emulator

emulator -avd simple_28

Surprise! No joy! Failed with a (PANIC)

Turns out to be the wrong "emulator" is being called

Silly me /s

The correct emulator should be {sdk_root}/emulator/emulator instead it is {sdk_root}/tools/emulator

There are a couple of ways to change which emulator is used but I leave that to you

With that out of the way...

Boom

Profit

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