Expand description
Supports Android-specific Java build and run tasks in Rust projects from a Cargo build script.
§Tools exposed by this crate
§Environment variables in use
ANDROID_HOMEorANDROID_SDK_ROOT: path to the Android SDK directory.ANDROID_BUILD_TOOLS_VERSION: the version of the Android build tools.- Examples:
33.0.1,34.0.0-rc2. - This must be fully specified all in one string.
- Examples:
ANDROID_PLATFORM,ANDROID_API_LEVEL, orANDROID_SDK_VERSION: the platform version string (aka API level, SDK version) being targeted for compilation.- All three of these environment variables are treated identically.
- Examples:
34,android-34,android-33,33. - If an SDK extension must be specified, use the full string with the
androidprefix like so:android-33-ext4. - This may or may not include the SDK extension level as a suffix
(see
ANDROID_SDK_EXTENSIONbelow).
ANDROID_SDK_EXTENSION: the extension of the Android SDK.- To specify
android-33-ext4, this can be set to-ext4,ext4, or just4. All of these will be treated identically. - If
ANDROID_PLATFORM/ANDROID_API_LEVEL/ANDROID_SDK_VERSIONalready includes an extension, thenANDROID_SDK_EXTENSIONwill be ignored.
- To specify
ANDROID_D8_JAR: the path to thed8.jarfile.ANDROID_JAR: the path to theandroid.jarfile.JAVA_HOME: the Java SDK directory.JAVA_SOURCE_VERSION: the Java version for source compatibility, which is passed to the--sourcejavac option, e.g.,8for Java 1.8, or17for Java 17.JAVA_TARGET_VERSION: the Java version for target compatibility, which is passed to the--targetjavac option, e.g.,7for Java 1.7, or17for Java 17.
§Acknowledgments
This crate simplifies some code found in other crates:
dirs-sysfor the Windows-specific home directory lookup.java-locatorfor finding the Java home directory on macOS, Linux, and Windows.jerkfor arguments that can be passed intojavaandjavaccommands.i-slint-backend-android-activityfor parsingjavacversion and finding the latest platform and build tools versions in the Android SDK installation.
Structs§
- Debug
Info - Debug information to include in the output of a
javacbuild. - Dexer
- A builder for generating Android DEX bytecode by invoking
d8commands. - Java
Build - A builder for a
javaccommand that can be invoked. - JavaRun
- A builder for a
javacommand that can be invoked.
Constants§
- ANDROID_
API_ LEVEL - ANDROID_
BUILD_ TOOLS_ VERSION - ANDROID_
D8_ JAR - ANDROID_
HOME - ANDROID_
JAR - ANDROID_
PLATFORM - ANDROID_
SDK_ EXTENSION - ANDROID_
SDK_ ROOT - ANDROID_
SDK_ VERSION - JAVA_
HOME - JAVA_
SOURCE_ VERSION - JAVA_
TARGET_ VERSION
Traits§
- PathExt
- An extension trait for checking if a path exists.
Functions§
- android_
d8_ jar - Returns the path to the
d8.jarfile for the given build tools version. - android_
jar - Returns the path to the
android.jarfile for the given API level. - android_
sdk - Returns the path to the Android SDK directory.
- check_
javac_ version - Returns the major version number of the
javaccompiler. - java
- Returns the path to the
javaexecutable by looking for$JAVA_HOME/bin/java. - java_
home - Returns the
JAVA_HOMEpath by attempting to discover it. - java_
source_ version - Returns the source version for compilation from environment variable
JAVA_SOURCE_VERSION. - java_
target_ version - Returns the target version for compilation from environment variable
JAVA_TARGET_VERSION. - javac
- Returns the path to the
javaccompiler by looking for$JAVA_HOME/bin/javac.