Tutorial Playing android games on Linux with Android Studio (emulator)

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
3,968
Reaction score
4,157
Credits
32,446
There have been numerous questions about android emulators for Linux and how to play Android games on Linux.

This guide is about how to use Android Studio to emulate games or to run Android software.

Android Studio is IDE that's normally used for Android development, however due to availability of all API's it' excellent choice to emulate any games or software out there that are available in google play store.
You can also play games from other stores if you install them ofc.

All together it will take at least 8GB of disk space.

First step is to download Android Studio, from the link below:

Click on "Download Android Studio" button, accept the terms and download to location of your choice.
In my case download file is named android-studio-panda2-linux.tar.gz, it's compressed file so when download is done we'll extract it.
You want to extract it to inside ~/ your home directory to be able to update the software without root privileges, otherwise you'll need to run the studio as root which is neither wise not convenient.

Bash:
# Directory where we'll keep the installation and future updates
mkdir ~/Android
# Replace file location and name below with what you've downloaded.
tar -xzvf ~/Downloads/android-studio-panda2-linux.tar.gz -C ~/Android

Next you want to create a desktop and programs menu shortcut:
Bash:
cd ~/.local/share/applications
nano AndroidStudio.desktop

Copy code below and paste into terminal, then replace USER with your username (output of id -un)
INI:
[Desktop Entry]
# 3 types of desktop entries: Application, Link and Directory
Type=Application
# Specific name of the application
Name=Android Studio
# Generic name of the application
GenericName=Android Studio
# Path to an executable file on disk used to determine if the program is actually installed
TryExec=/home/USER/Android/android-studio/bin/studio
# Program to execute, possibly with arguments
Exec=/home/USER/Android/android-studio/bin/studio
# If entry is of type Application, the working directory to run the program in.
Path=/home/USER/Android
# Icon to display in file manager, menus, etc
Icon=/home/USER/Android/android-studio/bin/studio.png
# Tooltip for the entry
Comment=Android Studio IDE
# Categories in which the entry should be shown in a menu
Categories=Game
# Whether the program runs in a terminal window
Terminal=false
# This application exists, but don't display it in the menus
NoDisplay=false
# If true, the application has a single main window, and does not support having an additional one opened
SingleMainWindow=true

When done editing press CTRL+O to save and CTRL+X to close.

For desktop shortcut to appear in programs menu, log out and log in again, you should find the icon in "Games" menu.
If for some reason this doesn't work you can run Android Studio directly from /home/USER/Android/android-studio/bin/, and run studio executable.

When you run it you can opt in to send usage statistics, this is optional.
You'll be greeted with "Welcome" window, click "Next" to continue.

Then you're asked about setup type, either "standard" or "custom", choose custom:

setup.png

Click "Next" and you're asked to select components...

components.png



Note that "Android Virtual Device" which we need for emulation may be grayed out as shown above, ignore it for now and hit "Next", "Next", accept the license, "Next", until you see window below:

emulator.png

In my case I already have KVM enabled and set up, but if you don't you'll need to set it up for better gaming performance which is significant, we'll be back to this step later, click "Next", accept listed libs with "Next" and finally click "Finish" to start downloading libraries.

When download is done click "Finish", the following window will appear:

new_project.png


Click on "New Project" and then "Next":
In the window that follows below, select "no activity" and click "Next":

no activity.png


In the window that comes next you can configure some project parameters, I'm fine with defaults and clicked "Finish":

finish.png


At this point the IDE will open, and we need to deal with the "Android Virtual Device" that was grayed out...
In my case it was installed despite not being selected, to confirm click on gear button in top right corner and select "SDK Manager" from drop down menu:

gear.png


Select "SDK Tools" as shown below and confirm "Android Emulator" is installed:

emulator2.png


If it's not installed try installing it.
If it's grayed out then we need to enable KVM and try again later...


Here is link to guide about how to enable it:

If you're lost with the guide, in short this is what you need to do on Debian based system:

Bash:
sudo apt update
sudo apt install qemu-system-x86 virt-manager
sudo adduser $(id -un) libvirt

For the adduser to take effect log out then wait (by default) 10 seconds before loging back in.
Verify with groups command you're added to libvirt group, if not wait longer after logout or reboot system and try again.

You'll also need to enable virtualization in BIOS, for intel system the option is called VT-x

When you're done to check whether KVM is enabled run emulator executable with -accel-check option:

Bash:
~/Android/Sdk/emulator/emulator -accel-check

Output of this command should be:
accel:
0
KVM (version 12) is installed and usable.
accel

Then if needed install Android Emulator from SDK Manager as shown previously.

Next we open the IDE and a add a virtual device, see image below, click on "Device Manager", click + button and "Add virtual device" from drop down menu:

device.png


You'll be offered a bunch of devices:

listdev.png


The column "Play" tells us whether play store is also included, this is what you need, other columns are about API level, you can think of higher API level as of newer model phone or tablet, however some games require minimum API level and probably maximum as well.
The width, height and density columns tell you about phone resolution.

For this tutorial I've selected "Pixel 7 Pro", click "Next" and "Finish" to download device of choice.
You can ofc. experiment with tablet and other types of devices.

When downloaded click on play button to start the phone:

playbtn.png


Next click on "Running Devices" in side bar:

mgr.png


When the Android OS starts up you can sign in to google play store, download games and play as you want.
Note that you can resize the phone, rotate etc. from the top menu bar, as well as forwarding keyboard input:

options.png


You can also resize the widget with phone to cover your entire screen.
I don't have google account to play a game but you should be able to figure out what to do from this point on ;)
 
Last edited:


idk i feel like there was a easier way then that the last time i played an android game its been years so om not really sure
 
Sure there's easier way, you can use waydroid or some other emulator, advantage of Android Studio is you can download multiple phone or tablet devices if a game doesn't work.
And you can set API level per device which gives flexibility.

You can also install some non google play game stores if you want to play out of store.

This setup is basically a virtual phone or tablet device, it's not just about games, you can also run various android software.

Another advantage is you don't need wayland, it works on X11 as well, while waydroid requires wayland.
 
I was just thinking about whether or not you could run Android apps on Linux. I have a bit of a weird project planned that I'd like to incorporate this into.

Basically the stereo in my Jeep broke down and I wanted to convert an old laptop or maybe a single board computer into a new media center/stereo and have it run Linux.

There's a ODBII scanner app for android called JScan that I use for diagnosing trouble codes and changing advanced settings that I would like to be able to use right on the dash. Once I get a computer for this, I'll try out this guide.
 
to convert an old laptop or maybe a single board computer into a new media center/stereo and have it run Linux.
Keep in mind that this setup uses virtualization, SBC or very old laptop may not support hardware virtualization.
You can run this without virtualization but with worse performance.

But you can ofc. try and see how it works.
 


Follow Linux.org

Members online


Top