Android Studio: Emulator
Summary
In this documentation, we cover the topic of how to run an Android emulator with Android Studio in Kali Linux.
This is not a detailed description of Android Studio, but only the configuration of a rooted emulator.
Requirements
- Operating System: Kali Linux
Setup
Download the newest version of Android Studio Iguana
Change the working directory to Downloads
cd Downloads/
Extract Android Studio with tar
tar -xzvf android-studio-2023.2.1.25-linux.tar.gz
Change the working directory to android-studio/bin
cd android-studio/bin
Start Android Studio
./studio.sh
Create Virtual Device
1. On the "Welcome to Android Studio" page, select More Actions.
2. Go into the Virtual Device Manager.
3. Click on the + icon to add a new device.
4. Choose a device based on your preferences. We chose Pixel 6 Pro.
5. Select an x86 image (we recommend Android 7 or higher) with Google APIs but not Google Play to use a non-production image. We chose Android 9 ("Pie"), API 28 without Google Play.
Set Environment Variables
Open the bashrc file
nano ~/.bashrc
Add to the end of the file the following line:
export PATH=$PATH:/home/kali/Android/Sdk/emulator
Save & Exit the file.
Execute the bashrc file to make the changes effective:
bash source ~/.bashrc
To check if variables are added to PATH.
echo $PATH
Problem Fix
If problems appear about missing environment variables, then add these lines to ~/.bashrc & execute the file.
export ANDROID_HOME=$HOME/Android/Sdk export ANDROID_SDK_ROOT=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools
To check if variables are added.
echo $PATH echo $ANDROID_SDK_ROOT echo $ANDROID_HOME
Run the Virtual Device in the Terminal
With the following command, the virtual device should be shown on the screen.
emulator -avd <DEVICE-NAME> -writable-system -no-snapshot
Example:
emulator -avd Pixel_6_Pro_API_28 -writable-system -no-snapshot
Now the emulator is ready to go!
Errors?
If any errors occur with the emulator, most errors can be solved by wiping the data of the device and starting anew.
For this, you have to open Android Studio, select the device manager, and click on "wipe data".