If you wish to use Android Studio then please follow the official guide to install and setup your environment. If you wish to install the minimal CLI tools only, then read below.
You can use the android command line tools to install the parts of the SDK required for development. All the files will be stored under $ANDROID_HOME, so you can easily remove them later.
This works by first downloading the command line tools, then using sdkmanager to download and boostrap the other components.
Download the command line tools from the offical site then follow these steps:
-
Create a folder that will be the ANDROID_HOME
mkdir -p /home/bob/android/sdk
-
Set ANDROID_HOME in your shell (you should also add this to your profile)
export ANDROID_HOME=/home/dave/android/sdk
-
Unpack the command line tools
unzip commandlinetools-mac-8092744_latest.zip -d $ANDROID_HOME
N.B due to an oddity with the command line tools package, after unpacking you need to move the binaries into a folder called latest
cd $ANDROID_HOME/cmdline-tools && mkdir latest && mv NOTICE.txt bin lib source.properties latest
-
Install Platform, Platform-tools, System Images and Emulator
## platform-tools echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install platform-tools ## platform (android 32) $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-32" ## System Images (android 32) echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "system-images;android-32;google_apis;x86_64"
-
If everything worked, when you ls the $ANDROID_HOME
ls $ANDROID_HOME
you should see the following output
cmdline-tools emulator licenses patcher platform-tools platforms system-images
-
Setup a virtual device. In the above steps we installed android-32 so we will use this version when setting up the device.
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager --verbose create avd --force --name "Pixel_4.4_API_32" --device "pixel" --package "system-images;android-32;google_apis;x86_64" --tag "google_apis" --abi "google_apis/x86_64"
Before setting up the emulator you should follow the steps above to install the Android SDK
-
To list what devices have been installed run the following command:
$ANDROID_HOME/emulator/emulator -list-avds
which gives output like so:
Pixel_2_API_30 Pixel_2_API_30_2 Pixel_4.4_API_32 Pixel_5_API_32
-
Start the emulator with desired device (prefix the name with @)
$ANDROID_HOME/emulator/emulator @Pixel_4.4_API_32
To connect to a local FF Server, you must enable clear text traffic. This can be done by adding the following to the project AndroidManifest.xml
<application>
android:usesCleartextTraffic="true"
</application>
Because you will be running an emulator, the localhost that your project is using will not be the same as where the FF-Server is running. You must use the host 10.0.2.2 (read more) which is bridged to your machines localhost.