For many of Android Developers who are using React Native to develop Android apps, it’s quite cumbersome to start testing their apps. They need to start Android Studio first and then run Emulator. It becomes especially tiring when you need to repeat the process each day. So today I will show you a quick way to start Emulator without running Android Studio. There are main two steps:
- Know Android SDK location and Emulator name
- Write and save batch script
Android SDK Location and Emulator Name
If you don’t know where Android SDK is installed don’t worry, I will show you how to know where it’s located. First of all, open Android Studio and open Tools->Android->SDK Manager. It will open up a dialog box like this:
Here you can see the Android SDK location showing the path. Note it down. Next thing is to find out the exact name of Emulator you wish to run. Now open Tools->Android->AVD Manager.
Note down the name of emulator name which you want to start. The main thing to know here is that you need to replace blank space with an underscore(_). So if I wish to use my emulator “Android 8.0”, I will use “Android_8.0” in the further process.
Writing Batch Script
Right-click on the desktop and click New->New Text Document. Name it anything but change the extension to “.bat”. For example, I created the file with name “emulator.bat”. Right click on this file and click “Edit”. Now we’ll start writing the actual script.
1. In the first line, write “cd <Drive Letter>:” (without quotes). For example, in my case, since the Android SDK is located on C drive, I will use the following command:
2. Now write “cd<space>” followed by the exact Android SDK address which we got in the first step:
3. In this final line, write:
emulator -avd Android_8.0 -netdelay none -netspeed full
Replace “Android_8.0” with the name of your emulator and that’s it! Save the bat file and try running it. It should start the emulator. The only thing you need to keep in mind that after running the script, a cmd window will open up. Don’t close that window otherwise emulator will close by itself.