Ubuntu/Android/SDK/AVD
From r00tedvw.com wiki
(Difference between revisions)
(Created page with "=Overview= Done on Ubuntu 20.04 LTS.<br> Installed without Android Studio =Download Prerequisites= Get the commandline tools.<br> [https://developer.android.com/studio https:/...") |
|||
Line 51: | Line 51: | ||
use <code>sudo visudo</code> then add the following to the '''<code>Defaults secure_path=</code>''' | use <code>sudo visudo</code> then add the following to the '''<code>Defaults secure_path=</code>''' | ||
<nowiki>Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/android/cmdline-tools/bin:/opt/android/cmdline-tools/latest:/opt/android/emulator:/opt/android/platform-tools"</nowiki> | <nowiki>Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/android/cmdline-tools/bin:/opt/android/cmdline-tools/latest:/opt/android/emulator:/opt/android/platform-tools"</nowiki> | ||
+ | |||
+ | =Install Android packages= | ||
+ | <nowiki>~$ cd /opt/android/ | ||
+ | ~$ sudo sdkmanager --sdk_root="/opt/android" --install "platforms;android-31" | ||
+ | ~$ sudo sdkmanager --sdk_root="/opt/android" --install "system-images;android-31;google_apis_playstore;x86_64" | ||
+ | ~$ sudo sdkmanager --sdk_root="/opt/android" --install "build-tools;31.0.0" | ||
+ | ~$ sudo sdkmanager --sdk_root="/opt/android" --licenses</nowiki> | ||
+ | Verify you can see them. | ||
+ | <nowiki>~$ sudo avdmanager list avd | ||
+ | Available Android Virtual Devices:</nowiki> |
Revision as of 03:02, 12 August 2021
Contents |
Overview
Done on Ubuntu 20.04 LTS.
Installed without Android Studio
Download Prerequisites
Get the commandline tools.
https://developer.android.com/studio > Download options > commandlinetools-linux-7583922_latest.zip
~$ wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
Make the directory Android SDK/AVD will live in.
~$ sudo mkdir /opt/android
Unzip
~$ sudo unzip ~/commandlinetools-linux-7583922_latest.zip -d /opt/android
Move sdkmanager
~$ sudo mkdir /opt/android/cmdline-tools/latest ~$ sudo mv /opt/android/cmdline-tools/bin/sdkmanager /opt/android/cmdline-tools/latest
Set Env Vars and Path
I had to do this in a few places. root, user, and sudoers.
root & user
Create a bash_alias for root, modify .profile for user. Same data in both.
~$ sudo touch /root/.bash_aliases ~$ sudo vim /root/.bash_aliases ~$ sudo vim ~/.profile # set PATH so it includes android sdk emulator if it exists if [ -d "/opt/android/emulator" ] ; then PATH="/opt/android/emulator:$PATH" fi # set PATH so it includes android sdk platform tools if it exists if [ -d "/opt/android/platform-tools" ] ; then PATH="/opt/android/platform-tools:$PATH" fi # set PATH so it includes android sdk command line tools if it exists if [ -d "/opt/android/cmdline-tools" ] ; then PATH="/opt/android/cmdline-tools:$PATH" fi # set PATH so it includes android sdk command line tools bin if it exists if [ -d "/opt/android/cmdline-tools/bin" ] ; then PATH="/opt/android/cmdline-tools/bin:$PATH" ANDROID_SDK_ROOT="/opt/android" ANDROID_HOME="/opt/android" fi # set PATH so it includes android sdk command line tools if it exists if [ -d "/opt/android/cmdline-tools/latest" ] ; then PATH="/opt/android/cmdline-tools/latest:$PATH" fi
sudoers
use sudo visudo
then add the following to the Defaults secure_path=
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/android/cmdline-tools/bin:/opt/android/cmdline-tools/latest:/opt/android/emulator:/opt/android/platform-tools"
Install Android packages
~$ cd /opt/android/ ~$ sudo sdkmanager --sdk_root="/opt/android" --install "platforms;android-31" ~$ sudo sdkmanager --sdk_root="/opt/android" --install "system-images;android-31;google_apis_playstore;x86_64" ~$ sudo sdkmanager --sdk_root="/opt/android" --install "build-tools;31.0.0" ~$ sudo sdkmanager --sdk_root="/opt/android" --licenses
Verify you can see them.
~$ sudo avdmanager list avd Available Android Virtual Devices: