Android: Difference between revisions

imported>Charlycoste
Seems that androidenv.platformTools is not available anymore
imported>Valodim
add some info on how to use gradlew
Line 75: Line 75:
<syntaxhighlight lang=console>
<syntaxhighlight lang=console>
$ nix-shell -p android-studio --run android-studio
$ nix-shell -p android-studio --run android-studio
</syntaxhighlight>
=== gradlew ===
It's possible to create a build environment (shell.nix) to use with gradlew as a FHS environment:
<syntaxhighlight lang=nix>
{ pkgs ? import <nixpkgs> {config.android_sdk.accept_license = true;} }:
(pkgs.buildFHSUserEnv {
  name = "android-sdk-env";
  targetPkgs = pkgs: (with pkgs;
    [
      androidenv.androidPkgs_9_0.androidsdk
      glibc
    ]);
}).env
</syntaxhighlight>
As an alternative, it's often enough to override just the aapt2 binary for the gradle build process:
<syntaxhighlight lang=nix>
{ pkgs ? import <nixpkgs> {config.android_sdk.accept_license = true;} }:
let
  androidSdk = pkgs.androidenv.androidPkgs_9_0.androidsdk;
in
pkgs.mkShell {
  buildInputs = with pkgs; [
    androidSdk
    glibc
  ];
  # override the aapt2 that gradle uses with the nix-shipped version
  GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/28.0.3/aapt2";
}
</syntaxhighlight>
</syntaxhighlight>