Android

From Gentoo Wiki
Jump to:navigation Jump to:search

Android is an operating system developed by the Open Handset Alliance, led by Google, and mainly used on smartphones, tablets and multimedia boxes. It mainly runs on the ARM 6 and 7 architecture, but it has also been ported to x86 and MIPS. It uses the Linux kernel with a custom userland which is Apache licensed.

Gentoo has some Android-specific packages:

Setting up an Android dev environment without Android Studio

To set up a development environment for Android without installing Android Studio (e.g. because you'd prefer to use app-editors/vim or app-editors/emacs for development):

  • Ensure none of the packages listed at the start of this page are installed, in order to avoid duplicate installations and potential conflicts.
root #emerge openjdk-bin
root #emerge app-eselect/eselect-java

and select the appropriate Java VM as the user under which you'll be doing development:

user $eselect java-vm list
Available Java Virtual Machines:
  [1]   openjdk-bin-8 
  [2]   openjdk-bin-17
user $eselect java-vm set user openjdk-bin-17
root #emerge acct-group/android
  • Add that user to the android group:
root #gpasswd -a <USER> android
  • Create a directory for the Android SDK, e.g. ~/android:
user $mkdir ~/android
user $unzip -d ~/android/ platform-tools_r34.0.5-linux.zip
user $unzip -d ~/android/ commandlinetools-linux-11076708_latest.zip
  • Configure the relevant path environment variables for your shell (e.g. in ~/.bash_profile):
CODE
export ANDROID_HOME="${HOME}/android"
export PATH="${PATH}:${ANDROID_HOME}/platform-tools";
export PATH="${PATH}:${ANDROID_HOME}/cmdline-tools/bin";

Apply the group and environment changes by logging the dev user out of any existing sessions, then logging that user back in again.

  • Use sdkamanager to list available platform SDK versions, and install the latest platform:
user $sdkmanager --sdk_root=~/android --list
user $sdkmanager --sdk_root=~/android --install "platforms;android-34"
  • Install the appropriate version of Android build-tools for that platform, and refresh cmdline-tools:
user $sdkmanager --sdk_root=~/android --install "build-tools;34.0.0"
user $sdkmanager --sdk_root=~/android --install "cmdline-tools;latest"
  • Review and accept the relevant licenses:
user $sdkmanager --sdk_root=~/android --licenses

Detailed information about environment variables affecting the Android SDK can be found at https://developer.android.com/tools/variables.

See also