Setup Android Environment on Linux

Install necessary packages

  1. Use crossbundle install command or download and install Android Studio.
  2. Start Android Studio, and go through the Android Studio Setup Wizard with the Custom option and install the following (or install them in SDK Manager):
    • Android SDK
    • NDK (Side by side)
    • Android SDK Command-line Tools
    • Android SDK Build-Tools
    • Android SDK Platform-tools

Install necessary rustup targets

Run the following command:

rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android

Add environment variables

From the Start search bar, enter env and select Edit environment variables for your account.

Building strategyKeyValueDescription
Gradle project, native APK/AABANDROID_SDK_ROOT<path_to_sdk>\SdkCan be replaced with ANDROID_SDK_PATH and ANDROID_HOME. You might not install this env var if you used crossbundle install to set up required packages
or just want to build native APK or native AAB
Native APK/AABANDROID_NDK_ROOT<path_to_sdk>\Sdk\ndk<version>Can be replaced with ANDROID_NDK_PATH and NDK_HOME. You might not install this env var if you used crossbundle install to set up required packages
Gradle projectGRADLE_HOME<path_to_gradle>Crossbow default build process requires installed Gradle on your PC. You can download it here
Native AABBUNDLETOOL_PATH<path_to_bundletool>Download bundletool from the GitHub repository or use crossbundle install

For that edit ~/.bash_profile or ~/.bashrc files so they contain those lines:

export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_NDK_ROOT=$HOME/Android/Sdk/ndk/23.1.7779620
export GRADLE_HOME=<path_to_gradle>
export BUNDLETOOL_PATH=<path_to_bundletool>

Also, we need to make sure we have a java runtime environment (JRE) installed. We need a key tool utility from there.
To make sure it's present type this command: ls /usr/lib/jvm/default/bin/ | grep keytool

But please be aware that your path may vary. The above path is for arch-based Linux.

If not, install JRE accordingly to your operating system: Examples:

  • Ubuntu: sudo apt install default-jdk
  • Manjaro (Arch): sudo pacman -S jre11-openjdk-headless jre11-openjdk jdk11-openjdk openjdk11-doc openjdk11-src

Set up your Android device

Follow the link to find out how to set up your device or android emulator

Next step

See hello-world to configure your project

After previous steps you can use crossbundle to build gradle project or native APK/AAB. Go to the links: