Android: Difference between revisions

From NixOS Wiki
imported>Makefu
No edit summary
imported>Makefu
No edit summary
Line 1: Line 1:
=== Connecting Android device ===
=== Connecting Android device ===
...
<syntaxhighlight lang=console>
$ nix-shell -p androidenv.platformTools
% adb connect 192.168.1.10
% adb shell
</syntaxhighlight>


=== Building Android apps using Nix ===
=== Building Android apps using Nix ===
Line 63: Line 67:


[https://nixos.org/nix-dev/2015-April/016881.html Source]
[https://nixos.org/nix-dev/2015-April/016881.html Source]
== Using the nixpkgs androidenv ==
User Sander van der Burg created two awesome blog posts as well as a number of test cases usable as examples on how to use the nixpkgs androidenv and the emulator provideded:
# [https://sandervanderburg.blogspot.de/2012/11/building-android-applications-with-nix.html  Building Android applications with the Nix package manager ]
# [https://sandervanderburg.blogspot.de/2012/11/building-android-applications-with-nix.html  Reproducing Android app deployments (or playing Angry Birds on NixOS)]
# [https://github.com/svanderburg/nix-androidenvtests A set of androidenv test cases]

Revision as of 20:04, 22 September 2017

Connecting Android device

$ nix-shell -p androidenv.platformTools
% adb connect 192.168.1.10
% adb shell

Building Android apps using Nix

Some software (for example Tinc VPN) have Android client which can be built together with the NixOS version, in the same derivation, sharing the same configuration options.

...

Android Studio on NixOS

$ nix-shell -p android-studio --run android-studio

Building Android on NixOS

It's possible to use nix-shell with buildFHSUserEnv to set up an environment in which it's viable to build Android without huge amounts of editing. This is an example shell.nix file.

{ pkgs ? import <nixpkgs> {} }:
 
let fhs = pkgs.buildFHSUserEnv {
  name = "android-env";
  targetPkgs = pkgs: with pkgs;
    [ git
      gitRepo
      gnupg
      python2
      curl
      procps
      openssl
      gnumake
      nettools
      androidenv.platformTools
      jdk
      schedtool
      utillinux
      m4
      gperf
      perl
      libxml2
      zip
      unzip
      bison
      flex
      lzop
    ];
  multiPkgs = pkgs: with pkgs;
    [ zlib
    ];
  runScript = "bash";
  profile = ''
    export USE_CCACHE=1
    export ANDROID_JAVA_HOME=${pkgs.jdk.home}
  '';
};
in pkgs.stdenv.mkDerivation {
  name = "android-env-shell";
  nativeBuildInputs = [ fhs ];
  shellHook = "exec android-env";

}

Source

Using the nixpkgs androidenv

User Sander van der Burg created two awesome blog posts as well as a number of test cases usable as examples on how to use the nixpkgs androidenv and the emulator provideded:

  1. Building Android applications with the Nix package manager
  2. Reproducing Android app deployments (or playing Angry Birds on NixOS)
  3. A set of androidenv test cases