Home Explore Blog Models CI



nixpkgs

2nd chunk of `doc/languages-frameworks/android.section.md`
4b2b599b48bfd67e867ebcb137110cf253996ee43d5b25930000000100000fa6
  under the `ndk` directory of the SDK root, and the first is linked under the
  `ndk-bundle` directory. It defaults to the latest.
* `ndkVersion` is equivalent to specifying one entry in `ndkVersions`, and
  `ndkVersions` overrides this parameter if provided.
* `includeExtras` is an array of identifier strings referring to arbitrary
  add-on packages that should be installed. Note that extras may not be compatible
  with all platforms (for example, the Google TV head unit, which does not
  have an aarch64-linux compile).
* `platformVersions` specifies which platform SDK versions should be included.
  It defaults to including only the latest API level, though you can add more.
* `numLatestPlatformVersions` specifies how many of the latest API levels to include,
  if you are using the default for `platformVersions`. It defaults to 1, though you can
  increase this to, for example, 5 to get the last 5 years of Android API packages.
* `minPlatformVersion` and `maxPlatformVersion` take priority over `platformVersions`
  if both are provided. Note that `maxPlatformVersion` always defaults to the latest
  Android SDK platform version, allowing you to specify `minPlatformVersion` to describe
  the minimum SDK version your Android composition supports.

For each platform version that has been specified, we can apply the following
options:

* `includeSystemImages` specifies whether a system image for each platform SDK
  should be included.
* `includeSources` specifies whether the sources for each SDK version should be
  included.
* `useGoogleAPIs` specifies that for each selected platform version the
  Google API should be included.
* `useGoogleTVAddOns` specifies that for each selected platform version the
  Google TV add-on should be included.

For each requested system image we can specify the following options:

* `systemImageTypes` specifies what kind of system images should be included.
  Defaults to: `default`.
* `abiVersions` specifies what kind of ABI version of each system image should
  be included. Defaults to `armeabi-v7a` and `arm64-v8a`.

Most of the function arguments have reasonable default settings, preferring the latest
versions of tools when possible. You can additionally specify "latest" for any plugin version
that you do not care about, and just want the latest of.

You can specify license names:

* `extraLicenses` is a list of license names.
  You can get these names from repo.json or `querypackages.sh licenses`. The SDK
  license (`android-sdk-license`) is accepted for you if you set accept_license
  to true. If you are doing something like working with preview SDKs, you will
  want to add `android-sdk-preview-license` or whichever license applies here.

Additionally, you can override the repositories that composeAndroidPackages will
pull from:

* `repoJson` specifies a path to a generated repo.json file. You can generate this
  by running `generate.sh`, which in turn will call into `mkrepo.rb`.
* `repoXmls` is an attribute set containing paths to repo XML files. If specified,
  it takes priority over `repoJson`, and will trigger a local build writing out a
  repo.json to the Nix store based on the given repository XMLs. Note that this uses
  import-from-derivation.

```nix
{
  repoXmls = {
    packages = [ ./xml/repository2-1.xml ];
    images = [
      ./xml/android-sys-img2-1.xml
      ./xml/android-tv-sys-img2-1.xml
      ./xml/android-wear-sys-img2-1.xml
      ./xml/android-wear-cn-sys-img2-1.xml
      ./xml/google_apis-sys-img2-1.xml
      ./xml/google_apis_playstore-sys-img2-1.xml
    ];
    addons = [ ./xml/addon2-1.xml ];
  };
}
```

When building the above expression with:

```bash
$ nix-build
```

The Android SDK gets deployed with all desired plugin versions.

We can also deploy subsets of the Android SDK. For example, to only the
`platform-tools` package, you can evaluate the following expression:

```nix
with import <nixpkgs> { };

let
  androidComposition = androidenv.composeAndroidPackages {
    # ...

Title: Advanced Android SDK Customization and Repository Configuration with Nix
Summary
This section continues detailing the advanced configuration options for `androidenv.composeAndroidPackages` in Nix, allowing precise control over Android SDK components. It covers parameters for NDK versions, additional add-on packages (`includeExtras`), and extensive control over platform SDK versions, including options for specifying ranges (`minPlatformVersion`, `maxPlatformVersion`), number of latest versions, and inclusion of system images, sources, Google APIs, and Google TV add-ons for each platform. Furthermore, it explains how to manage SDK licenses through `extraLicenses` and override default package repositories using `repoJson` or `repoXmls`, providing an example of how to specify custom repository XML files for fine-grained control over the SDK's package sources. The text concludes by indicating that subsets of the Android SDK can be deployed, such as only the `platform-tools` package.