android_prebuilt_aar
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.
Details
See the official Android documentation for details about the .aar format.
Function Signature
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",
_is_building_android_binary: bool = False,
_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,
uses_content_based_path_for_jar_snapshot: bool = select({"DEFAULT": False}),
) -> None
Parameters
-
name: (required)name of the target
-
default_target_platform: (defaults to:None)specifies the default target platform, used when no platforms are specified on the command line
-
target_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
exec_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with an execution platform
-
visibility: (defaults to:[])a list of visibility patterns restricting what targets can depend on this one
-
within_view: (defaults to:["PUBLIC"])a list of visibility patterns restricting what this target can depend on
-
metadata: (defaults to:{})a key-value map of metadata associated with this target
-
tests: (defaults to:[])a list of targets that provide tests for this one
-
modifiers: (defaults to:[])an array of modifiers associated with this target
-
aar: (required)Path to the
.aarfile. This may also be a build target to a rule (such as agenrule()) whose output is an.aarfile. -
contacts: (defaults to:[])A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.
contacts = [ 'Joe Sixpack', 'Erika Mustermann' ] -
javadoc_url: (defaults to:None)URL to the Javadoc for the
.classfiles in theaar. -
labels: (defaults to:[])Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query(). -
licenses: (defaults to:[])Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query
-
source_jar: (defaults to:None)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: (defaults to:False)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.
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' ],
)