Skip to main content

android_aar

An android_aar() rule is used to generate an Android AAR.

Details

See the official Android documentation for details about the .aar format.

Function Signature

def android_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] = {},
_cxx_toolchain: str = gh_facebook_buck2_shims_meta//:android-hack,
_is_building_android_binary: bool = True,
_is_force_single_cpu: bool = False,
_is_force_single_default_cpu: bool = False,
_java_toolchain: str = "gh_facebook_buck2_shims_meta//:java_for_android",
abi_generation_mode: None | str = None,
annotation_processing_tool: None | str = None,
annotation_processor_deps: list[str] = [],
annotation_processor_params: list[str] = [],
annotation_processors: list[str] = [],
build_config_values: list[str] = [],
build_config_values_file: None | str = None,
compress_asset_libraries: bool = False,
contacts: list[str] = [],
cpu_filters: list[str] = ["arm64", "armv7", "x86", "x86_64"],
deps: list[str] = [],
enable_relinker: bool = False,
excluded_java_deps: list[str] = [],
extra_arguments: list[str] = [],
extra_kotlinc_arguments: list[str] = [],
extra_relinker_outputs: list[str] = [],
friend_paths: list[str] = [],
hardcode_permissions_for_deterministic_output: None | bool = None,
include_build_config_class: bool = False,
java_version: None | str = None,
javac: None | str = None,
labels: list[str] = [],
language: None | str = None,
licenses: list[str] = [],
manifest: None | str = None,
manifest_entries: dict[str, typing.Any] = {},
manifest_file: None | str = None,
manifest_skeleton: str,
maven_coords: None | str = None,
min_sdk_version: None | int = None,
native_library_bolt_args: None | dict[str, list[str]] = None,
native_library_merge_code_generator: None | str = None,
native_library_merge_glue: None | str = None,
native_library_merge_linker_args: None | dict[str, list[str]] = None,
native_library_merge_linker_args_all: list[str] = [],
native_library_merge_map: None | dict[str, list[str]] = None,
native_library_merge_non_asset_libs: bool = False,
native_library_merge_sequence: None | list[list[(str, list[str])] | (str, list[str])] = None,
native_library_merge_sequence_blocklist: None | list[str] = None,
non_exec_dep_plugins_deprecated: list[str | (str, list[str])] = [],
package_asset_libraries: bool = True,
package_resources: bool = True,
plugins: list[str | (str, list[str])] = [],
proguard_config: None | str = None,
relinker_extra_args: dict[str, list[str]] = {},
relinker_extra_args_all: list[str] = [],
relinker_extra_deps: list[str] = [],
relinker_whitelist: list[str] = [],
remove_classes: list[str] = [],
required_for_source_only_abi: bool = False,
resource_union_package: None | str = None,
resources: list[str] = [],
resources_root: None | str = None,
runtime_deps: list[str] = [],
source: None | str = None,
source_abi_verification_mode: None | str = None,
source_only_abi_deps: list[str] = [],
srcs: list[str] = [],
strip_libraries: bool = True,
target: None | str = None,
use_jvm_abi_gen: None | bool = None,
) -> 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

  • abi_generation_mode: (defaults to: None)

    Overrides .buckconfig for this rule.

  • build_config_values: (defaults to: [])

    See the documentation on the values argument for android_build_config().

  • 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' ]
  • deps: (defaults to: [])

    List of build targets whose corresponding compiled Java code, Android resources, and native libraries will be included in the AAR along with their transitive dependencies. For compile time deps which should not be included in the final AAR, use provided_deps instead. * android_library() Will be included in the final classes.jar* android_resource() Will be included in the final R.txt, res/ and assets/* android_build_config() Will be included in the final classes.jar if include_build_config_class is True * groovy_library() Will be included in the final classes.jar* java_library() Will be included in the final classes.jar* prebuilt_jar() Will be included in the final classes.jar* prebuilt_native_library() Will be included in the final jni/ or assets/ if is_asset is True

  • hardcode_permissions_for_deterministic_output: (defaults to: None)

    If set to true, Buck hardcodes the permissions in order to ensures that all files have the same permissions regardless of the platform on which the zip was generated.

  • include_build_config_class: (defaults to: False)

    Whether to include the BuildConfig class files in the final .aar file. Needs to be set to True if any build_config_values are specified. This is normally only needed if the build tool that is consuming the .aar file does not generate BuildConfig classes. Note: the AAR format does not specify a way to pass defaults that should be injected into the final BuildConfig class, therefore that information might need to be replicated manually in the build that's consuming the .aar file.

  • javac: (defaults to: None)

    Specifies the Java compiler program to use for this rule. The value is a source path or an execution dep (e.g., //foo/bar:bar). Overrides the value in "javac" in the "tools" section of .buckconfig.

  • 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

  • manifest_skeleton: (required)

    The skeleton manifest file used to generate the final AndroidManifest.xml . May either be a file or an android_manifest() target.

  • native_library_merge_linker_args_all: (defaults to: [])

    Extra linker arguments passed to all merged libraries.

  • non_exec_dep_plugins_deprecated: (defaults to: [])

    Plugins that do not use the execution platform. This exists for historical reasons, and should not be used. Use plugins instead - plugins should be configured for the execution platform since that is where they are used.

  • plugins: (defaults to: [])

    List of plugins that should be run during compilation of the target. A list of strings may additionally be provided in order to pass additional arguments to the plugin.

  • relinker_extra_args: (defaults to: {})

    Per-library extra linker arguments passed when relinking, mapping sonames to lists of arguments.

  • relinker_extra_args_all: (defaults to: [])

    Extra arguments passed when relinking all libraries.

  • relinker_extra_deps: (defaults to: [])

    Deps statically linked to every native lib by the relinker.

  • remove_classes: (defaults to: [])

    List of classes to remove from the output aar. It removes classes from the target's own sources, and its dependencies.

Examples


android_resource(
name = 'res',
res = 'res',
assets = 'assets',
package = 'com.example',
)

android_library(
name = 'lib',
srcs = glob(['**/*.java']),
)

android_aar(
name = 'app',
manifest_skeleton = 'AndroidManifestSkeleton.xml',
deps = [
':res',
':lib',
],
)