Buck: android_resource()
Support Ukraine. Help Provide Humanitarian Aid to Ukraine.

android_resource()

An android_resource() rule is used to bundle Android resources that are traditionally stored in res and assets directories.

The output of an android_resource() is an R.txt file generated via aapt --output-text-symbols.

Arguments

  • name (required) #

    The short name for this build target.

  • res (defaults to None) #

    A dictionary mapping relative resource paths to either the resource files or the build targets that generate them. The subdir_glob() function can be used to generate dictionaries based on a directory structure of files checked into the repository. Alternatively, this can be a path to a directory containing Android resources, although this option is deprecated and might be removed in the future.

  • package (defaults to None) #

    Java package for the R.java file that will be generated for these resources.

  • assets (defaults to None) #

    A dictionary mapping relative asset paths to either the asset files or the build targets that generate them. The subdir_glob() function can be used to generate dictionaries based on a directory structure of files checked into the repository. Alternatively, this can be a path to a directory containing Android assets, although this option is deprecated and might be removed in the future.

  • project_res (defaults to None) #

    A directory containing resources to be used for project generation. If not provided, defaults to whatever the build uses.

  • project_assets (defaults to None) #

    A directory containing assets to be used for project generation. If not provided, defaults to whatever the build uses.

  • manifest (defaults to None) #

    An optional Android Manifest for the resource to declare any permissions or intents it may need or want to handle. May either be a file or a android_manifest target.

  • deps (defaults to None) #

    Other android_resource rules to include via -S when running aapt.

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their deps or exported_deps attributes. For more information, see visibility.

  • 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.

  • 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 attrfilter().

Examples

Most of the time, an android_resource rule defines only name, res, and package. By convention, such simple rules are often named res:
android_resource(
  name = 'res',
  res = subdir_glob([('res', '**')]),
  package = 'com.example',
)