android studio

Table of Contents

1 Android studio

This document collects how I run android development environment on my linux machine. I do most of it throught the command line because I really can’t stand using the android studio GUI applications.

1.1 Vocabulary

there’s some interesting vocabulary in android world that is totally worth learning

avd : Android Virtual Device, also known as emulator

adb : Android Debug Bridge: a cli utility to conenct to the devices over cli

log all android things:

log just a few modules

set an env variable in the avd :

1.2 Setting up android command line management

here is a small guide on how to get started with android development largely without touching the studio GUI on arch linux, but it could probably be changed up to work with other versions of linux

1.2.1 install the requirements

most of these requirements are installed from the aur (Arch User Repositories) using the yay package manager, which should be installed separately.

yay -S android-studio # not actually sure we need this if we have the below
                      # is this just the GUI?
yay -S android-sdk
yay -S android-sdk-build-tools
yay -S android-sdk-platform-tools
yay -S android-emulator
#  sudo pacman -S android-tools # removed in favor of build tools?

# we need some specific versions of jave to get everything running
sudo pacman -S jre8-openjdk

1.2.2 changing permissions

sudo groupadd android-sdk
sudo gpasswd -a YOUR_USERNAME android-sdk

sudo setfacl -R -m g:android-sdk:rwx /opt/android-sdk
sudo setfacl -d -m g:android-sdk:rwX /opt/android-sdk
newgrp android-sdk

1.2.3 creating avds:

if you came from the previous steps directly, then before creating your avds, you have to log out and log back in

much of the followint came from this gist, so thank you for that

sudo archlinux-java set java-8-openjdk/jre

# first, create a system image
sdkmanager --install "system-images;android-29;google_apis;x86"

# then create an _emulator_ of that system image, notice the --name option here,
# this is how you will run the emulator in the future
avdmanager \
    --verbose \
    create avd \
    --force \
    --name "pixal" \
    --device "pixel" \
    --package "system-images;android-29;google_apis;x86" \
    --tag "google_apis" \
    --abi "x86"

# for running other things
sudo archlinux-java set java-13-openjdk

# project RM, as well as many react-native projects need
sudo archlinux-java set java-10-openjdk
  1. adding keyboard support to your emulator

    to enable the keyboard in the emulator you just created in the step above, you have to edit it’s config file. taken from this stackoverflow

    Please edit the file ~/.android/avd/[YOUR_AVD_NAME].avd/config.ini and add the following lines. In the example above we used the name pixal

    # ~/.android/avd/[YOUR_AVD_NAME].avd/config.ini

1.2.4 Running the emulator(s)

Running them is also done through the avd name that you chose earlier.

NOTE: you need to have hardware (cpu) virtualization turned on for the emulators to run. check out the docs here, but I just had to turn “virtualization” on in my BIOS settings

emulator @pixal

1.3 development: connecting a new adb device:

to be honest I forgot what this was usedfor.

→ sudo adb kill-server
→ sudo adb start-server
daemon not running; starting now at tcp:5037

Author: John Doe

Created: 2021-04-25 Sun 15:53