android_manifest
An android_manifest()
rule is used to generate an Android Manifest to be used by android_binary()
and android_aar()
rules. This rule takes a skeleton manifest, and merges it with manifests found in any deps.
Function Signature
def android_manifest(
*,
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] = {},
contacts: list[str] = [],
default_host_platform: None | str = None,
deps: list[str] = [],
labels: list[str] = [],
licenses: list[str] = [],
skeleton: str,
) -> 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
-
deps
: (defaults to:[]
)A collection of dependencies that includes android_library rules. The manifest files of the
android_library()
rules will be filtered out to become dependent source files for the manifest. -
skeleton
: (required)Either a
build target
or a path to a file representing the manifest that will be merged with any manifests associated with this rule'sdeps
.
Examples
Here's an example of an android_manifest()
that has no deps.
android_manifest(
name = 'my-manifest',
skeleton = 'AndroidManifestSkeleton.xml',
)
This is what AndroidManifestSkeleton.xml
looks like.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk targetSdkVersion="19" minSdkVersion="17"/>
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
<activity
android:name="MyActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
You could also use a genrule()
to generate the manifest file and reference the
build target
in the skeleton
argument.