android_prebuilt_aar
android_prebuilt_aar
def android_prebuilt_aar(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str] = [],
within_view: list[str] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
_android_toolchain: str = "gh_facebook_buck2_shims_meta//:android",
_apple_platforms: dict[str, str] = {},
_build_only_native_code: bool = select({"prelude//android/constraints:build_only_native_code": True, "DEFAULT": False}),
_dex_min_sdk_version: None | int = select({"prelude//android/constraints:min_sdk_version_19": 19, "prelude//android/constraints:min_sdk_version_20": 20, "prelude//android/constraints:min_sdk_version_21": 21, "prelude//android/constraints:min_sdk_version_22": 22, "prelude//android/constraints:min_sdk_version_23": 23, "prelude//android/constraints:min_sdk_version_24": 24, "prelude//android/constraints:min_sdk_version_25": 25, "prelude//android/constraints:min_sdk_version_26": 26, "prelude//android/constraints:min_sdk_version_27": 27, "prelude//android/constraints:min_sdk_version_28": 28, "prelude//android/constraints:min_sdk_version_29": 29, "prelude//android/constraints:min_sdk_version_30": 30, "prelude//android/constraints:min_sdk_version_31": 31, "prelude//android/constraints:min_sdk_version_32": 32, "prelude//android/constraints:min_sdk_version_33": 33, "prelude//android/constraints:min_sdk_version_34": 34, "prelude//android/constraints:min_sdk_version_35": 35, "DEFAULT": None}),
_dex_toolchain: str = "gh_facebook_buck2_shims_meta//:dex",
_exec_os_type: str = "prelude//os_lookup/targets:os_lookup",
_java_toolchain: str = "gh_facebook_buck2_shims_meta//:java_for_android",
aar: str,
contacts: list[str] = [],
default_host_platform: None | str = None,
deps: list[str] = [],
desugar_deps: list[str] = [],
dex_weight_factor: int = 1,
for_primary_apk: bool = False,
javadoc_url: None | str = None,
labels: list[str] = [],
licenses: list[str] = [],
maven_coords: None | str = None,
required_for_source_only_abi: bool = True,
source_jar: None | str = None,
use_system_library_loader: bool = False,
) -> None
An android_prebuilt_aar() rule takes an .aar file and makes it available as an Android dependency. As expected, an android_binary() that transitively depends on an android_prebuilt_aar() will include its contents in the generated APK.
Parameters
name: name of the targetdefault_target_platform: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility: a list of visibility patterns restricting what targets can depend on this onewithin_view: a list of visibility patterns restricting what this target can depend onmetadata: a key-value map of metadata associated with this targettests: a list of targets that provide tests for this onemodifiers: an array of modifiers associated with this targetaar: Path to the.aarfile. This may also be a build target to a rule (such as agenrule()) whose output is an.aarfile.javadoc_url: URL to the Javadoc for the.classfiles in theaar.source_jar: Path to a JAR file that contains the.javafiles to create the.classin theaar. This is frequently provided for debugging purposes.use_system_library_loader: If this.aarfile contains native prebuilt.solibraries and the Java code uses these libraries via a call toSystem.loadLibrary(), then many optimizations—such as exopackage, compression, or asset packaging—may not be compatible with these prebuilt libs. Setting this parameter toTruecauses all of these optimizations to skip the prebuilt.sofiles originating from this.aarfile. The.sofiles will always be packaged directly into the main.apk.
Details
See the official Android documentation for details about the .aar format.
Examples:
android_prebuilt_aar(
name = 'play-services',
aar = 'play-services-4.0.30.aar',
source_jar = 'play-services-4.0.30-sources.jar',
javadoc_url = 'file:///opt/android-sdk/extras/google/google_play_services/docs/reference',
)
android_library(
name = 'lib',
# This Java code can compile against Play services and reference its resources.
srcs = glob(['*.java']),
deps = [ ':play-services' ],
)