React Native android simulator on Windows with Expo
Couple days ago I started experimenting with React Native. It was an easy ride except for the moments when it wasn’t.
With my freshly bootstrapped CRNA project using Expo, I’ve managed to run it on my physical Android device. For some simple things, it is more than a satisfactory solution and mostly people might even prefer it over a simulator. In my opinion it’s just easier way of development when you see device on your screen, use regular keyboard to write there or simulate GPS.
I’ve installed Genymotion as instructed in Expo docs. The first bump was a total crash of Windows when starting virtual device. After some digging, I found out I need to disable Hyper-V. I am not entirely sure why is that, but it helped. Now I have a functional simulator of an Android phone, yay!
I’ve started Expo XDE as usual, everything running and I tried clicking on “Install Android App” in the menu. That did not work out well as XDE is not able to connect with a simulator just like that…
The key here is that Genymotion needs to be using the same SDK as the Expo. Apparently, it’s then able to create some communication bridge; I don’t understand details much. The manual is suggesting to use the same SDK as employed by Genymotion, but after a deep search, I wasn’t able to find out its location on Windows.
Another option is to install Android Studio and instruct Genymotion and XDE to use SDK from there. Honestly, I am confused here why it’s not possible to use same SDK that XDE is using (or not?). Anyway, I am always very reluctant in installing new software on Windows, especially when it has over 2GB! So I’ve decided to follow a harder path.
There is an option to download some SDK tools from referenced website, but Genymotion wasn’t happy about just that. There is a tool sdk_manager.bat
included which allows downloading other stuff. The problem is that no one tells you what stuff you need. After couple hours of fiddling, I’ve given up.
Then it struck me. I can install Android Studio into a sandbox and just grab that SDK it uses! And indeed, it worked great. The installer even shows the path where SDK is going to be installed. After couple minutes of waiting, I had necessary files on my drive, finally. Uhh, and what now…?
What is the sandbox? I bet you can google it but in a sense, it’s similar to virtual machine except it’s not virtual, running on your machine and much more secure and isolated; perfect for dangerous waters of the internet.
Expo docs are explaining that it should be possible to run adb
from the terminal. Installing Android Studio does that for you (among other ugly stuff). Otherwise, you can simply add folder platform-tools
from the SDK folder to PATH environment variable.
Now you can simply follow rest of instruction to tell Genymotion where the SDK tools are. For the XDE you need to run exp path
to copy updated PATH environment variable. And that’s it.
I can imagine this is probably much more straightforward way when you don’t bother and just install Android Studio, but at least you will learn something new here :)