Git Product home page Git Product logo

android-nixpkgs's Introduction

Android Nixpkgs

All packages from the Android SDK repository, packaged with Nix.

Updated daily from Google's Android SDK repositories.

Install

Requirements

Currently we support the following platforms:

  • aarch64-darwin: MacOS on Apple Silicon
  • x86_64-darwin: MacOS on x86-64
  • x86_64-linux: Linux on x86-64

You should have nix installed, either because your're awesome and run NixOS, or you have installed it from nixos.org.

Channel

If you're not using flakes, Nix channel is provided which contains stable, beta, preview, and canary releases of the Android SDK package set.

nix-channel --add https://tadfisher.github.io/android-nixpkgs android-nixpkgs
nix-channel --update android-nixpkgs

The sdk function is provided to easily compose a selection of packages into a usable Android SDK installation.

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

let
  android-nixpkgs = callPackage <android-nixpkgs> {
    # Default; can also choose "beta", "preview", or "canary".
    channel = "stable";
  };

in
android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
  cmdline-tools-latest
  build-tools-34-0-0
  platform-tools
  platforms-android-34
  emulator
])

If you save this in something like sdk.nix, you can get a dev environment with nix-shell. This will result in ANDROID_HOME and ANDROID_SDK_ROOT being set in your environment.

nix-shell sdk.nix

Here's an example shell.nix which includes Android Studio from Nixpkgs and a working SDK.

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

let
  android-nixpkgs = callPackage <android-nixpkgs> { };

  android-sdk = android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
    cmdline-tools-latest
    build-tools-34-0-0
    platform-tools
    platforms-android-34
    emulator
  ]);

in
mkShell {
  buildInputs = [
    android-studio
    android-sdk
  ];
}

Ad-hoc

If you don't want to set up a channel, and you don't use Nix flakes, you can import android-nixpkgs using builtins.fetchGit:

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

let
  android-nixpkgs = callPackage (import (builtins.fetchGit {
    url = "https://github.com/tadfisher/android-nixpkgs.git";
  })) {
    # Default; can also choose "beta", "preview", or "canary".
    channel = "stable";
  };

in
android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
  cmdline-tools-latest
  build-tools-34-0-0
  platform-tools
  platforms-android-34
  emulator
])

Flake

If you live on the bleeding edge, you may be using Nix Flakes. This repository can be used as an input to your project's flake.nix to provide an immutable SDK for building Android apps or libraries.

{
  description = "My Android app";

  inputs = {
    android-nixpkgs = {
      url = "github:tadfisher/android-nixpkgs";

      # The main branch follows the "canary" channel of the Android SDK
      # repository. Use another android-nixpkgs branch to explicitly
      # track an SDK release channel.
      #
      # url = "github:tadfisher/android-nixpkgs/stable";
      # url = "github:tadfisher/android-nixpkgs/beta";
      # url = "github:tadfisher/android-nixpkgs/preview";
      # url = "github:tadfisher/android-nixpkgs/canary";

      # If you have nixpkgs as an input, this will replace the "nixpkgs" input
      # for the "android" flake.
      #
      # inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, android-nixpkgs }: {
    packages.x86_64-linux.android-sdk = android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
      cmdline-tools-latest
      build-tools-34-0-0
      platform-tools
      platforms-android-34
      emulator
    ]);
  };
}

A project template is provided via templates.android. This also provides a devShell with a configured Android SDK; on Linux platforms, Android Studio is also provided.

nix flake init -t github:tadfisher/android-nixpkgs
nix develop
android-studio    # available on x86_64-linux platforms

See flake.nix in the generated project to customize the SDK and Android Studio version.

Home Manager

A Home Manager module is provided to manage an Android SDK installation for the user profile. Usage depends on whether you are using Home Manager via flakes.

Normal

In home.nix:

{ config, pkgs, ... }:

let
  androidSdkModule = import ((builtins.fetchGit {
    url = "https://github.com/tadfisher/android-nixpkgs.git";
    ref = "main";  # Or "stable", "beta", "preview", "canary"
  }) + "/hm-module.nix");

in
{
  imports = [ androidSdkModule ];

  android-sdk.enable = true;

  # Optional; default path is "~/.local/share/android".
  android-sdk.path = "${config.home.homeDirectory}/.android/sdk";

  android-sdk.packages = sdkPkgs: with sdkPkgs; [
    build-tools-34-0-0
    cmdline-tools-latest
    emulator
    platforms-android-34
    sources-android-34
  ];
}

Flake

An example flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    android-nixpkgs = {
      url = "github:tadfisher/android-nixpkgs";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, home-manager, android-nixpkgs }: {

    nixosConfigurations.x86_64-linux.myhostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        home-manager.nixosModules.home-manager

        {
          home-manager.users.myusername = { config, lib, pkgs, ... }: {
            imports = [
              android-nixpkgs.hmModule

              {
                inherit config lib pkgs;
                android-sdk.enable = true;

                # Optional; default path is "~/.local/share/android".
                android-sdk.path = "${config.home.homeDirectory}/.android/sdk";

                android-sdk.packages = sdk: with sdk; [
                  build-tools-34-0-0
                  cmdline-tools-latest
                  emulator
                  platforms-android-34
                  sources-android-34
                ];
              }
            ];
          };
        }
      ];
    };
  };
}

List SDK packages

Channel

Unfortunately, this is a little rough using stable Nix, but here's a one-liner.

nix-instantiate --eval -E "with (import <android> { }); builtins.attrNames packages.stable" --json | jq '.[]'

Flake

nix flake show github:tadfisher/android-nixpkgs

Troubleshooting

Android Studio is using the wrong SDK installation directory.

Unfortunately, Android Studio persists the configuration for android.sdk.path in several locations:

  • In local.properties within the project. This is regenerated whenever syncing with the build system. A possible way to prevent this (and avoid the following steps) is to remove the sdk.dir property and set the file read-only with chmod -w local.properties.
  • In ~/.config/Google/AndroidStudio{Version}/options/jdk.table.xml. Search for the string "Android SDK" and remove the entire surrounding <jdk> element.
  • In the workspace configuration, which may live in .idea/workspace.xml in the project, or in ~/.config/Google/AndroidStudio{Version}/workspace/{hash}.xml. Search for the string "android.sdk.path" and remove the element.

A method to configure Android Studio (and IntelliJ IDEA) via Nix would be cool, but also a tedious endeavor.

The SDK Manager complains about a read-only SDK directory.

This is fine; you cannot install packages via the SDK Manager to a Nix-built SDK, because the point of this project is to make your build dependencies immutable. Either update your Nix expression to include the additional packages, or switch to using a standard Android SDK install.

When using a standard installation downloaded from the Android Developers site, if you're running NixOS then you may have to run patchelf to set the ELF interpreter for binaries referencing standard paths for the system linker. The binaries may work inside Android Studio built from nixpkgs, as it runs in a FHS-compliant chroot.

License

Licensed under the MIT open-source license. See COPYING for details.

android-nixpkgs's People

Contributors

5aaee9 avatar eliasnaur avatar elizagamedev avatar j4nv5 avatar mange avatar maximoffua avatar name-snrl avatar rickvanprim avatar soywod avatar tadfisher avatar tcmulcahy avatar timor avatar yangm97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

android-nixpkgs's Issues

com.android.sdkmanager.toolsdir is unset, causing avdmanager to traverse the entire nix store

tl;dr at bottom.

I'm currently on x86_64-darwin, but I don't suspect that changes things (wouldn't be the first time, though...). The error occurs with anything that gets the cmdline-tools-latest, although I strongly suspect it will also trigger on the other cmdline- tools versions.

I noticed this first because avdmanager list --verbose avd hangs for several minutes, finally spitting out multiple path collisions that indicate it has traversed the entire nix store looking for stuff.

The wrapper already sets JAVA_OPTS to include -Dcom.android.sdklib.toolsdir in pkgs/android/cmdline-tools.nix, but in line 31 of $out/share/android-sdk/cmdline-tools/latest/bin/avdmanager, you can see that the default jvm opts is set to DEFAULT_JVM_OPTS='-Dcom.android.sdkmanager.toolsdir=$APP_HOME'

So since that is actually in an entirely separate directory, and the java wrapper tries very hard to chase all symlinks and then traverse up, it'll crawl the entire nix store looking for the right directory. Sigh. (It gets better: because it crawls the whole nix store, it eventually "works" but finds the first set of system images, which isn't necessarily the right one).

As an interesting aside, if you sit there and let things happen, because of how it traverses things and tries to find the right path, any avd created with avdmanager is going to end up with ~/.android/avd/${yourDevice}.avd/config.ini containing a image.sysdir.1=store/$nix_store_hash-android-env/share/android-sdk/system-images/android-XX/... prefix rather than the expected image.sysdir.1=system-images/android-XX/...


Long story short, this seems to completely resolve things on my system. avdmanager no longer traverses the entire nix store and hangs for 5 minutes.

diff --git a/pkgs/android/cmdline-tools.nix b/pkgs/android/cmdline-tools.nix
index 0a91db3..7181200 100644
--- a/pkgs/android/cmdline-tools.nix
+++ b/pkgs/android/cmdline-tools.nix
@@ -9,7 +9,8 @@ mkGeneric
       makeWrapper $script $out/bin/$(basename $script) \
         --set-default JAVA_HOME "${jdk.home}" \
         --set-default ANDROID_SDK_ROOT $ANDROID_SDK_ROOT \
-        --prefix JAVA_OPTS ' ' "-Dcom.android.sdklib.toolsdir=$pkgBase"
+        --prefix JAVA_OPTS ' ' "-Dcom.android.sdklib.toolsdir=$pkgBase" \
+        --prefix JAVA_OPTS ' ' "-Dcom.android.sdkmanager.toolsdir=$pkgBase"
       done
   '';
 }

Should I open up a PR for that?

PS: It's a good thing avdmanager isn't written in rust. It might've been so performant I wouldn't have even noticed 😜

Build failure of build-tools-28-0-3

Getting a build failure for build-tools-28-0-3
Removing lld from the postUnpack's for loop seems to fix it.

❯ nix log /nix/store/2jbfagq3qndwqkprgdglyrc757i5h1l5-build-tools-28-0-3-28.0.3.drv
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/2jbfagq3qndwqkprgdglyrc757i5h1l5-build-tools-28-0-3-28.0.3.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/2fj05lybgc3i98z20ks4w6qhnz9v1z53-build-tools_r28.0.3-linux.zip
source root is /nix/store/03bm5vzkkl0m7cvd0hkka8fx42yk3b3r-build-tools-28-0-3-28.0.3
substituteStream(): WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. (file '/nix/store/03bm5vzkkl0m7cvd0hkka8fx42yk3b3r-build-tools-28-0-3-28.0.3/apksigner')
substitute(): ERROR: file '/nix/store/03bm5vzkkl0m7cvd0hkka8fx42yk3b3r-build-tools-28-0-3-28.0.3/lld' does not exist
/nix/store/3qnm3nwjajgqa771dmi2dnwxrw0kzq5m-stdenv-linux/setup: line 131: pop_var_context: head of shell_variables not a function context

setup-hook: No such file or directory

Here's my sdk.nix (copied from readme):

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

let
  androidSdkPackages = callPackage <android> {
    # Default; can also choose "beta", "preview", or "canary".
    channel = "stable";
  };

in
  androidSdkPackages.sdk (apkgs: with apkgs; [
    cmdline-tools-latest
    build-tools-30-0-2
    platform-tools
    platforms-android-30
    emulator
  ])

Then I run:

$ nix-shell sdk.nix
Using Android SDK root: /nix/store/14l19x60cmdm19qydfsq15xy4pbha3v5-android-sdk-env/share/android-sdk
bash: /nix/store/14l19x60cmdm19qydfsq15xy4pbha3v5-android-sdk-env/nix-support/setup-hook: No such file or directory

[nix-shell:~]$

And I get that "no such file" error. Also the ANDROID_HOME var isn't set correctly (it's set to what it is in my global bash env from which I ran nix-shell.

NixOS cannot start dynamically linked executable: `emulator` command

When using the flake provided by nix flake init -t github:tadfisher/android-nixpkgs on nixOS, I cannot use the emulator command (/nix/store/86myy4i3igzb3g2s3ld154y9rfqgb7qp-android-project-dir/bin/emulator). I am getting the error:

Could not start dynamically linked executable: /nix/store/86myy4i3igzb3g2s3ld154y9rfqgb7qp-android-project-dir/bin/emulator
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld

Is this expected behaviour? How else should I start an emulator?

How to add System Images from this channel?

Hello Mister.
I want to ask about how to install system images fro Android development with this channel? I add system-images-android-33-google_apis-x86_64 in configuration but it throw error on nixos-rebuild switch command. How must I do?
Thanks for respond my isue, and sorry my English

cmake-3-22-1 mysteriously broken on darwin x86_64

Getting exit code 137 instantly. Couldn't get it to run under gdb as it mumbled about the binary not being valid (probably not prepared to handle universal binaries but that's just a guess).

Console.app didn't have any indication of this being a code signing issue, quite the contrary it shows as being allowed as a developer tool.

It seems like the binary extracted straight from the zip works, so I'm trying to guess what could be happening wrong with the derivation from this repo (which seems to not touch the binaries much?).

macOS: 13.5.1 (22G90)
nix (Nix) 2.15.1

Code signature stripped on Darwin

I'm having trouble running the RenderScript compiler, llvm-rs-cc because code signatures are stripped from a dylib in build-tools. This is relevant part of the error I'm hitting:

/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/lib/libbcinfo.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?))

and the full error if you're an avid reader:

dyld[67033]: Library not loaded: @rpath/libbcinfo.dylib
  Referenced from: /nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/llvm-rs-cc
  Reason: tried: '/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/../lib64/libbcinfo.dylib' (no such file), '/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/lib64/libbcinfo.dylib' (code signature in <29EBED16-7F80-352A-800D-1461AD671135> '/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/lib/libbcinfo.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)), '/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/../lib64/libbcinfo.dylib' (no such file), '/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/lib64/libbcinfo.dylib' (code signature in <29EBED16-7F80-352A-800D-1461AD671135> '/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/lib/libbcinfo.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)), '/usr/lib/libbcinfo.dylib' (no such file)

I can check the signatures with codesign. libbcinfo.dylib has an ad-hoc signature:

codesign --display --verbose /nix/store/sbvgm391717xz44fq1s3q0pwd7xpgzcr-android-sdk-env/share/android-sdk/build-tools/32.0.0/lib/libbcinfo.dylib
Executable=/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/lib/libbcinfo.dylib
Identifier=libbcinfo.dylib
Format=Mach-O thin (x86_64)
CodeDirectory v=20400 size=2792 flags=0x2(adhoc) hashes=82+2 location=embedded
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=0 size=12

and llvm-rs-cc is signed, by Google presumably:

Executable=/nix/store/gxylpsxax2xad9dljfw0dqa47zbsss3r-build-tools-32-0-0-32/llvm-rs-cc
Identifier=llvm-rs-cc
Format=Mach-O thin (x86_64)
CodeDirectory v=20500 size=7510 flags=0x10000(runtime) hashes=229+2 location=embedded
Signature size=9041
Timestamp=Nov 19, 2021 at 3:53:41 AM
Info.plist=not bound
TeamIdentifier=EQHXZ8M8AV
Runtime Version=10.13.0
Sealed Resources=none
Internal requirements count=1 size=172

This brings us to the bug in android-nixpkgs. When I download the build tools ZIP directly, both llvm-rs-cc and libbcinfo.dylib are signed:

$ codesign --display --verbose ~/Downloads/android-12/lib64/libbcinfo.dylib                                                                        
Executable=/Users/nsmith/Downloads/android-12/lib64/libbcinfo.dylib
Identifier=libbcinfo
Format=Mach-O thin (x86_64)
CodeDirectory v=20500 size=2805 flags=0x10000(runtime) hashes=82+2 location=embedded
Signature size=9041
Timestamp=Nov 19, 2021 at 3:53:40 AM
Info.plist=not bound
TeamIdentifier=EQHXZ8M8AV
Runtime Version=10.13.0
Sealed Resources=none
Internal requirements count=1 size=172

$ codesign --display --verbose ~/Downloads/android-12/llvm-rs-cc           
Executable=/Users/nsmith/Downloads/android-12/llvm-rs-cc
Identifier=llvm-rs-cc
Format=Mach-O thin (x86_64)
CodeDirectory v=20500 size=7510 flags=0x10000(runtime) hashes=229+2 location=embedded
Signature size=9041
Timestamp=Nov 19, 2021 at 3:53:41 AM
Info.plist=not bound
TeamIdentifier=EQHXZ8M8AV
Runtime Version=10.13.0
Sealed Resources=none
Internal requirements count=1 size=172

Is there a way to preserve the signatures from the originals?

nix-channel argument order reversed

In current README.md:

nix-channel --add android https://tadfisher.github.io/android-nixpkgs

I think it should be

nix-channel --add https://tadfisher.github.io/android-nixpkgs android 

ndk-26-1-10909125 fails on macOS

The issue in my nix flake:

image

Solution

The nix package for ndk tries loading .zip file for macOS builds but the release doesn't have a .zip for macs. Instead, it has .dmg.

wget https://dl.google.com/android/repository/android-ndk-r26b-darwin.zip # Doesn't work
wget https://dl.google.com/android/repository/android-ndk-r26b-darwin.dmg # Works and should be used

@tadfisher can you take a look or point me at how to solve this?

Emulator crashes on Hyprland due to emulator-wrapped.exe

When i try to run the emulator by launching an app in Android Studio i get error message:

The emulator process for AVD Pixel_5_API_34 has terminated

The problem is fixed if i replace the files .emulator-wrapped.exe and emulator.txt in the emulator package with emulator.exe from google's official emulator package. It looks like there is some issue with the wrapping. I am not sure why android-nixpkgs can't just use the standard `emulator.exe' file. Has anyone experienced the same problem and knows how to fix?

Steps to Reproduce

  1. add android-nixpkgs to nixos machine via home-manager module below.
  2. launch android-studio.
  3. provide SDK Location: File -> Project Structure -> SDK Location -> enter /home/$USER/Android/Sdk.
  4. add AVD: Tools -> Device Manager -> Create Device -> follow instructions to create Pixel_5_API_34 device.
  5. launch emulator.
  6. observe crash log output below in /home/$USER/.cache/Google/AndroidStudio2022.3/log/idea.log.

System Details

  • OS: NixOS Unstable
  • Shell: Bash
  • Android Studio: Hedgehog 2023.1.1
  • Desktop Environment: Hyprland (XWayland enabled)

Contents of emulator/emulator.txt:

#! /nix/store/q8qq40xg2grfh9ry1d9x4g7lq4ra7n81-bash-5.2-p21/bin/bash -e
export QT_QPA_PLATFORM='xcb'
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+':'$LD_LIBRARY_PATH':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/':''/nix/store/iidxwcyp8pqhrq3iji17shs4m6gin0kv-systemd-254.6/lib'':'/':'}
LD_LIBRARY_PATH='/nix/store/iidxwcyp8pqhrq3iji17shs4m6gin0kv-systemd-254.6/lib'$LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH#':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH%':'}
export LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+':'$LD_LIBRARY_PATH':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/':''/nix/store/jnlxl2ry9y03vq4skhm26igfd84xwa93-dbus-1.14.10-lib/lib'':'/':'}
LD_LIBRARY_PATH='/nix/store/jnlxl2ry9y03vq4skhm26igfd84xwa93-dbus-1.14.10-lib/lib'$LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH#':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH%':'}
export LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+':'$LD_LIBRARY_PATH':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/':''/nix/store/53ch4im2ziqjjhr08fphwxkclkqmrqkp-libudev0-shim-1/lib'':'/':'}
LD_LIBRARY_PATH='/nix/store/53ch4im2ziqjjhr08fphwxkclkqmrqkp-libudev0-shim-1/lib'$LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH#':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH%':'}
export LD_LIBRARY_PATH
export QT_XKB_CONFIG_ROOT='/nix/store/vrybs7z641yn0qkk4g9h8q5waxa9ljlp-xkeyboard-config-2.40/share/X11/xkb'
export QTCOMPOSE='/nix/store/y8f8j7nb52l30cg8x0clk9k91fpi224v-libX11-1.8.7/share/X11/locale'
exec -a "$0" "/nix/store/vdrgqk9mwqzpg89b5yvkfzf3xy87g05a-emulator-34.2.1/.emulator-wrapped" "$@"

Is flake usage wrong?

android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
      cmdline-tools-latest
      build-tools-32-0-0
      platform-tools
      platforms-android-31
      emulator
    ]);

(from README) does not work for me. Complains that android-nixpkgs.sdk is not a function. Seems like android-nixpkgs.sdk.${system} works (still building as I'm typing this).

Why does this exist

Why would I use this over androidComposition in nixpkgs? If this is better in some way, why not upstream it to nixpkgs?

devshell.nix incompatibility with aarch64

Line 28 of https://github.com/tadfisher/android-nixpkgs/blob/main/template/devshell.nix#L28 refers to android-studio, which isn't supported on aarch64. This results in confusing error messages for people on aarch64 (i.e. anyone on a M* Mac). (These can be fixed by removing android-studio manually, but it's not very discoverable that you need to do that)

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'android-project'
         whose name attribute is located at /nix/store/8s2477ph23ipnml56axnr9r7j0z7ywd5-source/nix/mkNakedShell.nix:30:10

       … while evaluating attribute 'args' of derivation 'android-project'
         at /nix/store/8s2477ph23ipnml56axnr9r7j0z7ywd5-source/nix/mkNakedShell.nix:38:3:
           37|   # Bring in the dependencies on `nix-build`
           38|   args = [ "-ec" "${coreutils}/bin/ln -s ${profile} $out; exit 0" ];
             |   ^
           39|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'android-studio' missing
       at /nix/store/0w59l4y8aswylmd4909im5rk209spwh0-source/flake.nix:13:31:
           12|     {
           13|       overlay = final: prev: {
             |                               ^
           14|         inherit (self.packages.${final.system}) android-sdk android-studio;

How to install a AVD? -> Cannot invoke "java.nio.file.Path.getFileSystem()" because "path" is null

I wonder how I install an AVD ... if there is a configuration option, or I am supposed to install it via a shellHook.

I am using a flake.nix with home manager on a M3 Mac.

When running

avdmanager create avd -n test -k 'system-images;android-33;google_atd;x86_64'

in the direnv directory, or

nix develop -c avdmanager create avd -n test -k 'system-images;android-33;google_atd;x86_64'

I am getting

Cannot invoke "java.nio.file.Path.getFileSystem()" because "path" is null

Is this due to a write protected nix-store location? Or is that another error?
All tools and pathes seem to be installed correctly; their respective x --version return something.

here are the relevant parts of my flake.nix:

{
  description = "Flutter toolchain. Installs all tools needed for flutter, with versions pinned for this project. Rust's own tooling handles the rust toolchain.";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    android-nixpkgs.url = "github:tadfisher/android-nixpkgs";
  };

  outputs = { nixpkgs, flake-utils, android-nixpkgs, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = {
            allowUnfree = true;
            android_sdk = {
              accept_license = true;
            };
          };
        };
        androidCustomPackage = android-nixpkgs.sdk.${system} (
          sdkPkgs: with sdkPkgs; [
            cmdline-tools-latest
            # build-tools-30-0-3
            # build-tools-33-0-2
            build-tools-34-0-0
            platform-tools
            emulator
            #patcher-v4
            # platforms-android-28
            # platforms-android-29
            # platforms-android-30
            # platforms-android-31
            # platforms-android-32
            # platforms-android-33
            platforms-android-34
            system-images-android-34-aosp-atd-arm64-v8a
            system-images-android-34-google-apis-arm64-v8a
            system-images-android-34-google-apis-x86-64
          ]
        );
        pinnedJDK = pkgs.jdk17;
      in
      {
        devShells. default = pkgs.mkShellNoCC {
          name = "My-flutter-dev-shell";
          buildInputs = with pkgs; [
            cocoapods
            pinnedJDK
            androidCustomPackage
          ];
          shellHook = ''
          '';
          JAVA_HOME = pinnedJDK;
          ANDROID_HOME = "${androidCustomPackage}/share/android-sdk";
          ANDROID_SDK_HOME = "${androidCustomPackage}/share/android-sdk";
        };
      }
    );
}

The flake does not work on Apple Sillicon (aarch64-apple-darwin)

What

The flake does not work, when following the readme, I followed the steps manually

Info

Used nix pkgs version: nix (Nix) 2.15.1

Problem

After entering the commands specified in the readme:

nix flake init -t github:tadfisher/android-nixpkgs
nix develop

The nix develop command fails with:

➜   nix develop
warning: Git tree '/Users/tester/dev/flutter-nix-hello-world' is dirty
warning: creating lock file '/Users/tester/dev/flutter-nix-hello-world/flake.lock'
warning: Git tree '/Users/tester/dev/flutter-nix-hello-world' is dirty
error: flake 'git+file:///Users/tester/dev/flutter-nix-hello-world' does not provide attribute 'devShells.aarch64-darwin.default', 'devShell.aarch64-darwin', 'packages.aarch64-darwin.default' or 'defaultPackage.aarch64-darwin'
       Did you mean devShell?

Investigation

By extending the line in flake.nix as:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: -> flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system: I get an error message:

error: Package ‘android-studio-stable-2022.2.1.20’ in /nix/store/6ysp0jddm896d8nn1pvj5pdaj72yra7i-source/pkgs/applications/editors/android-studio/common.nix:207 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
           "x86_64-linux"
         ]

Problem with the environment when using Gradle-managed devices on MacOS x86

Encountered an issue with gradle managed devices on MacOS x86. A sample project demonstrating the problem can be found here.

Reproduction Steps:

To replicate the issue, execute the following command:
nix develop -c ./test.sh

This command executes successfully on a Mac M2 but fails on a Mac Pro x86, resulting in the following Gradle error:

FAILURE: Build failed with an exception.

[org.gradle.internal.buildevents.BuildExceptionReporter]

* What went wrong:

Execution failed for task ':app:pixel4api33Setup'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.ManagedDeviceSetupTask$ManagedDeviceSetupRunnable

   > java.lang.IllegalStateException: Gradle was not able to complete device setup for: dev33_google_atd_x86_64_Pixel_4

     The emulator failed to open the managed device to generate the snapshot.

     This is because the emulator closed unexpectedly, try updating the emulator and

     ensure a device can be run from Android Studio.

The full log file is attached to this issue. Here is some key highlights:

[INFO] [com.android.build.gradle.internal.AvdManager] qemu: could not load PC BIOS 'bios-256k.bin'
[INFO] [com.android.build.gradle.internal.AvdManager] libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
[INFO] [com.android.build.gradle.internal.AvdManager] [48197:116410850:20240413,105527.346458:WARNING crash_report_exception_handler.cc:235] UniversalExceptionRaise: (os/kern) failure (5)

Within the logs, a command used to run qemu:

/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/qemu/darwin-x86_64/qemu-system-x86_64-headless -dns-server 192.168.0.1 -no-audio -serial stdio -device goldfish_pstore,addr=0xff018000,size=0x10000,file=/tmp/.android/.android/avd/gradle-managed/dev33_google_atd_x86_64_Pixel_4.avd/data/misc/pstore/pstore.bin -cpu android64-xts -enable-hvf -smp cores=2 -m 2048 -lcd-density 440 -nodefaults -kernel /nix/store/vg5yy6lsrli9dk8bba839nrzq0bllkwy-android-sdk-env/share/android-sdk/system-images/android-33/google_atd/x86_64//kernel-ranchu -initrd /tmp/.android/.android/avd/gradle-managed/dev33_google_atd_x86_64_Pixel_4.avd/initrd -drive if=none,index=0,id=system,if=none,file=/nix/store/vg5yy6lsrli9dk8bba839nrzq0bllkwy-android-sdk-env/share/android-sdk/system-images/android-33/google_atd/x86_64//system.img,read-only -device virtio-blk-pci,drive=system,modern-pio-notify -drive if=none,index=1,id=cache,if=none,file=/tmp/.android/.android/avd/gradle-managed/dev33_google_atd_x86_64_Pixel_4.avd/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=cache,modern-pio-notify -drive if=none,index=2,id=userdata,if=none,file=/tmp/.android/.android/avd/gradle-managed/dev33_google_atd_x86_64_Pixel_4.avd/userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=userdata,modern-pio-notify -drive if=none,index=3,id=encrypt,if=none,file=/tmp/.android/.android/avd/gradle-managed/dev33_google_atd_x86_64_Pixel_4.avd/encryptionkey.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=encrypt,modern-pio-notify -drive if=none,index=4,id=vendor,if=none,file=/nix/store/vg5yy6lsrli9dk8bba839nrzq0bllkwy-android-sdk-env/share/android-sdk/system-images/android-33/google_atd/x86_64//vendor.img,read-only -device virtio-blk-pci,drive=vendor,modern-pio-notify -netdev user,id=mynet -device virtio-net-pci,netdev=mynet -chardev null,id=forhvc0 -chardev null,id=forhvc1 -device virtio-serial-pci,ioeventfd=off -device virtconsole,chardev=forhvc0 -device virtconsole,chardev=forhvc1 -chardev netsim,id=bluetooth -device virtserialport,chardev=bluetooth,name=bluetooth -device virtio-serial,ioeventfd=off -chardev socket,port=53196,host=::1,nowait,nodelay,reconnect=10,ipv6,id=modem -device virtserialport,chardev=modem,name=modem -device virtio-rng-pci -show-cursor -device virtio_input_multi_touch_pci_1 -device virtio_input_multi_touch_pci_2 -device virtio_input_multi_touch_pci_3 -device virtio_input_multi_touch_pci_4 -device virtio_input_multi_touch_pci_5 -device virtio_input_multi_touch_pci_6 -device virtio_input_multi_touch_pci_7 -device virtio_input_multi_touch_pci_8 -device virtio_input_multi_touch_pci_9 -device virtio_input_multi_touch_pci_10 -device virtio_input_multi_touch_pci_11 -netdev user,id=virtio-wifi,dhcpstart=10.0.2.16 -device virtio-wifi-pci,netdev=virtio-wifi -device virtio-vsock-pci,guest-cid=77 -L /nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/lib/pc-bios -soundhw virtio-snd-pci -vga none -append 'no_timer_check 8250.nr_uarts=1 clocksource=pit console=ttyS0,38400 cma=294M@0-4G loop.max_part=7 ramoops.mem_address=0xff018000 ramoops.mem_size=0x10000 memmap=0x10000$0xff018000 printk.devkmsg=on bootconfig' -android-hw /tmp/.android/.android/avd/gradle-managed/dev33_google_atd_x86_64_Pixel_4.avd/hardware-qemu.ini

Troubleshooting Attempts

While unsure about the appropriateness of manually invoking this command (because Gradle can add some stuff to env), it was attempted. However, the following error was encountered:

dyld[48655]: Library not loaded: @rpath/libemugl_common.dylib
  Referenced from: <4C4C44A4-5555-3144-A129-31904C046B48> /nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/qemu/darwin-x86_64/qemu-system-x86_64-headless
  Reason: tried: '/nix/store/lib64/qt/lib/libemugl_common.dylib' (no such file), '/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/qemu/darwin-x86_64/libemugl_common.dylib' (no such file), '/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/qemu/darwin-x86_64/lib64/libemugl_common.dylib' (no such file), '/nix/store/lib64/qt/lib/libemugl_common.dylib' (no such file), '/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/qemu/darwin-x86_64/libemugl_common.dylib' (no such file), '/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/qemu/darwin-x86_64/lib64/libemugl_common.dylib' (no such file), '/usr/lib/libemugl_common.dylib' (no such file, not in dyld cache)

Upon investigation, libemugl_common.dylib was found at the following location:
/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/lib

As a workaround, the directory containing libemugl_common.dylib was added to the DYLD_LIBRARY_PATH environment variable using the following script:
export DYLD_LIBRARY_PATH="/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/lib:$DYLD_LIBRARY_PATH"

This action resolved the previous error, but resulted in a new message:

INFO    | Duplicate loglines will be removed, if you wish to see each individual line launch with the -log-nofilter flag.
unknown option: -serial
please use -help for a list of valid options

AAPT2 daemon startup failed

I create clean react native app and then init the flake setup with nix flake init -t github:tadfisher/android-nixpkgs.
When im trying to run yarn react-native run-android the error says

  • What went wrong:
    Execution failed for task ':app:processDebugResources'.
    Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
    Failed to transform appcompat-1.4.1.aar (androidx.appcompat:appcompat:1.4.1) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/1b40e4574e76bff5831ef4bf4270480d/transformed/appcompat-1.4.1.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #1: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.
    Failed to transform core-1.7.0.aar (androidx.core:core:1.7.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
    > Execution failed for AarResourcesCompilerTransform: /home/eekrain/.gradle/caches/transforms-3/63a3df243d2d102452600006144a86df/transformed/core-1.7.0.
    > AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
    This should not happen under normal circumstances, please file an issue if it does.

Can i use it with react native? Im really hopeless, dont have any idea to make an android environment in nixos.

`ndk-21-4-7075529` fails to build due to missing libpython2.7

It seems like ndk-21-4-7075529 (at least; I did not test any other NDK package) fails to build due
to a missing dependency of libpython2.7 during fixup. Overriding the package to also include python27 fixes this (for me).

Flake to reproduce
{
  description = "My Android project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    devshell.url = "github:numtide/devshell";
    flake-utils.url = "github:numtide/flake-utils";
    android.url = "github:tadfisher/android-nixpkgs";
  };

  outputs = { self, nixpkgs, devshell, flake-utils, android }:
    {
      overlay = final: prev: {
        inherit (self.packages.${final.system}) android-sdk android-studio;
      };
    }
    //
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = {
                allowUnfree = true;
        };

          overlays = [
            devshell.overlays.default
            self.overlay
          ];
        };
      in
      {
        packages = {
          android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; [
            # Useful packages for building and testing.
            build-tools-30-0-2
            cmdline-tools-latest
            emulator
            platform-tools
            platforms-android-30
            ndk-21-4-7075529
          ]);
        };
      }
    );
}

Build using nix build .#android-sdk.

The build failure
auto-patchelf: 7 dependencies could not be satisfied
error: auto-patchelf could not satisfy dependency libpython2.7.so.1.0 wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/liblldb.so
error: auto-patchelf could not satisfy dependency libpython2.7.so.1.0 wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/liblldb.so.9.0.9svn
error: auto-patchelf could not satisfy dependency libpython2.7.so.1.0 wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/liblldb.so.9svn
warn: auto-patchelf ignoring missing liblog.so wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/lib/linux/libclang_rt.asan-x86_64-android.so
warn: auto-patchelf ignoring missing liblog.so wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/lib/linux/libclang_rt.scudo-x86_64-android.so
warn: auto-patchelf ignoring missing liblog.so wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/lib/linux/libclang_rt.scudo_minimal-x86_64-andro>
warn: auto-patchelf ignoring missing liblog.so wanted by /nix/store/0si65fkwivqnhvqcf6d9zaq3b2brkzdg-ndk-21-4-7075529-21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/lib/linux/libclang_rt.ubsan_standalone-x86_64-an>
auto-patchelf failed to find all the required dependencies.
Add the missing dependencies to --libs or use `--ignore-missing="foo.so.1 bar.so etc.so"`.
/nix/store/fzb9wy1yz0hn69vxw12954szvrjnjjgk-stdenv-linux/setup: line 144: pop_var_context: head of shell_variables not a function context

I only included the end as that's the only occurence of the string error.

The workaround

As already mentioned, I was able to build the NDK package by just overriding it and including python27 in its build inputs.

{
  description = "My Android project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    devshell.url = "github:numtide/devshell";
    flake-utils.url = "github:numtide/flake-utils";
    android.url = "github:tadfisher/android-nixpkgs";
  };

  outputs = { self, nixpkgs, devshell, flake-utils, android }:
    {
      overlay = final: prev: {
        inherit (self.packages.${final.system}) android-sdk android-studio;
      };
    }
    //
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = {
                allowUnfree = true;
              permittedInsecurePackages = [
                "python-2.7.18.6"
              ];

        };

          overlays = [
            devshell.overlays.default
            self.overlay
          ];
        };
      in
      {
        packages = {
          android-sdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; [
            # Useful packages for building and testing.
            build-tools-30-0-2
            cmdline-tools-latest
            emulator
            platform-tools
            platforms-android-30
            (ndk-21-4-7075529.overrideAttrs (old: {
                buildInputs = old.buildInputs ++ [ pkgs.python27 ];
            }))
          ]);
        };
      }
    );
}

EDIT: I tested this with all four available channels. On every channel, the build failed with the exact same error.

Usage with devbox

Hey!

I keep my nix system config in devbox:
https://www.jetpack.io/devbox/docs/

I would like to use this repository, but I can not set the ANDROID_HOME env variable.

My current devbox.json looks something like this:

{
  "packages": [
    "neovim@latest",
    "docker@latest",
    "lazygit@latest",
    "dart@latest",
    "flutter@latest",
    "jdk11@latest",
    "openjdk11@latest",
    "android-tools@latest",
    "sdkmanager@latest",
    "github:tadfisher/android-nixpkgs#cmdline-tools-latest",
    "github:tadfisher/android-nixpkgs#build-tools-34-0-0",
    "github:tadfisher/android-nixpkgs#emulator",
    "github:tadfisher/android-nixpkgs#platforms-android-34",
    "github:tadfisher/android-nixpkgs#ndk-26-1-10909125",
    "github:tadfisher/android-nixpkgs#platform-tools"
  ],
  "shell": {
    "init_hook": [
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

I can set up env variables in the init_hook section, like they do in the rust setup example: https://www.jetpack.io/devbox/docs/configuration/#example-a-rust-devbox

any ideas how to make it work?

Support `aarch64-linux`

This is particularly useful when developing with VM setups like what lima offers by default.

Not sure what this will take exactly, and am relatively new to nix, so sorry for not being more useful in providing a PR!

Usage

Hey man, I am trying to figure out how to use this pkg, would you say this is a minimal working config?

{ config, lib, pkgs, ... }:

with lib;

let
  packages = sdk: with sdk; [
    tools
  ];
  android-sdk = (import <android> {}).sdk (p: packages p.stable);
in {
  config = (mkMerge [

    ({
      home.packages = with pkgs; [
        android-sdk
      ];
      xdg.dataFile."android".source = "${android-sdk}/share/android-sdk";
    })

  ]);
}

I am installing it through home-manager through nix-os, and getting the follow error:

--- home/anthony ‹master* M?› » TERM=xterm darwin-rebuild switch             
building the system configuration...
error: i686 Linux package set can only be used with the x86 family.
(use '--show-trace' to show detailed location information)

Also I assumed based on your repo that this worked on Darwin?

Usage on NixOS

I use NixOS and would like to set up the Android environment globally. I managed to start a nix shell with the environment using the provided file. I did not figure out, how to add it to the configuration.nix. Is there a way to import the shell file into the configuration? Or is there a way to adapt the code, so it is possible to paste it into a config file?

"attribute 'androidSdk' missing" error with home-manager&flake setup

I tried to install it via home-manager but I got this error.
How to solve it?

building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/store/iqxdbcjlg9wx8gdc8bdhy9nsd5imcbjp-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         elsewhile evaluating the attribute 'value'

         at /nix/store/iqxdbcjlg9wx8gdc8bdhy9nsd5imcbjp-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'androidSdk' missing

       at /nix/store/ii782kg2ikak79z4n8ksrzlmiz6czx35-source/hm-module.nix:48:32:

           47|   config = mkIf (cfg.enable) {
           48|     android-sdk.finalPackage = pkgs.androidSdk cfg.packages;
             |                                ^
           49|
       Did you mean androidsdk?

Upstream files changed?

error: hash mismatch in fixed-output derivation '/nix/store/w7hmkcv8n8rf8iyq9y5mgjy4ywfix0bd-arm64-v8a-32_r06.zip.drv':
         specified: sha1-9kVG98/NdR2JyLd5nURGdrIXxiM=
            got:    sha1-npfX7NW2y52RQby6rsE0ggrFaeE=
> nix-hash --to-base16 sha1-9kVG98/NdR2JyLd5nURGdrIXxiM=
f64546f7cfcd751d89c8b7799d444676b217c623

I think it's the second time I'm seeing this happen. What are the reasons these files change? Is it expected and something we have to live with?

Configuring an emulator?

Hi! First time nix user here. I've been trying to run and configure an android emulator for a react-native project but I just can't find a way to do it. I tried googling and this is what I've found:

{pkgs ? import <nixpkgs> {config.android_sdk.accept_license = true; config.allowUnfree = true;}}:
with pkgs;

androidenv.emulateApp {
  name = "emu";
  platformVersion = "33";
  enableGPU = false;
  abiVersion = "x86_64";
  avdHomeDir = "/home/alice/.avd";
}

However when I try running it wit:

nix-shell emu.nix

it doesn't do anything, not even a print to the console.

My shell.nix with all the env config is this:

{ pkgs ? import <nixpkgs> { config.android_sdk.accept_license = true; config.allowUnfree = true; } }:

with pkgs;


let
  android-nixpkgs = callPackage <android-nixpkgs> { };

  android-sdk = android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
    cmdline-tools-latest
    build-tools-32-0-0
    platform-tools
    platforms-android-33
    emulator
  ]);
  android_sdk.accept_license = true;

  nodejs = pkgs.nodejs-16_x;
  yarn = pkgs.yarn.override { inherit nodejs; };

in

mkShell {
  buildInputs = [
    android-studio
    android-sdk
    nodejs
    yarn
    jdk11
  ];

  shellHook = ''
    export NODE_OPTIONS=--openssl-legacy-provider
    export NIXPKGS_ALLOW_UNFREE=1
    
  '';
}

Executables not runnable

I tried to use some build tools, but I always get the same error: Could not start dynamically linked executable. It happened while I'm trying to build an Android app. The issue is not the same if running by hand or during a build env:

  • By hand:
    $ /nix/store/psrz7yh75aiblnwwjan08mi54mp2apf1-android-sdk-env/share/android-sdk/build-tools/34.0.0/zipalign 
    Could not start dynamically linked executable: /nix/store/psrz7yh75aiblnwwjan08mi54mp2apf1-android-sdk-env/share/android-sdk/build-tools/34.0.0/zipalign
    NixOS cannot run dynamically linked executables intended for generic
    linux environments out of the box. For more information, see:
    https://nix.dev/permalink/stub-ld
    
  • In a build env:
    > /nix/store/xfhkjnpqjwlf6hlk1ysmq3aaq80f3bjj-stdenv-linux/setup: line 123: /nix/store/w5fm31fb3lj7k8c518n7a36dh1kk667d-build-tools-34-0-0-34/zipalign: cannot execute: required file not found
    > /nix/store/xfhkjnpqjwlf6hlk1ysmq3aaq80f3bjj-stdenv-linux/setup: line 131: pop_var_context: head of shell_variables not a function context
    

The issue is the same with the following commands: aapt, aapt2, aidl, bcc_compat, d8, dexdump, lld, llvm-rs-cc, splitèselect and zipalign.

Seems related to #99 but I am not sure.

Ad-hoc Example Not Working

I used the Ad-hoc example: https://github.com/tadfisher/android-nixpkgs#ad-hoc

I ran nix-shell to get it setup but then the SDK root doesn't seem valid:

$ nix-shell 
Using Android SDK root: /nix/store/hf254wpxf4nn9q8a8yqf83n49yjjim71-android-sdk-env/share/android-sdk

$ sdkmanager --update
Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: <sdk>/cmdline-tools/latest/

$ ls /nix/store/hf254wpxf4nn9q8a8yqf83n49yjjim71-android-sdk-env/share/android-sdk
ls: cannot access '/nix/store/hf254wpxf4nn9q8a8yqf83n49yjjim71-android-sdk-env/share/android-sdk': No such file or directory

Any ideas?

cmake coming from android-sdk cannot find ICU

Now this might not be a problem actually related to android-nixpkgs, but I don't know where else to ask.

I'm trying to get a React Native project going with the "new architecture", which tries to build the Hermes engine, which fails by not finding ICU.

I've added icu.dev to the buildInputs but it doesn't seem to change anything, I can tell that the whole contraption to build Hermes is picking up the cmake coming from the android-sdk, but I can't tell how to tell that cmake that icu.dev exists, send help.

This be how I'm building the android-sdk:

        android-sdk = android.sdk.${system} (pkgs: with pkgs; [
          cmdline-tools-latest
          build-tools-31-0-0
          platform-tools
          platforms-android-31
          patcher-v4
          cmake-3-18-1
          ndk-bundle
          ndk-24-0-8215888
          ndk-21-4-7075529
        ]);

Flutter: Android license status unknown

It appears the use of this library with flutter does successfully include Android SDK, but flutter doctor says ✗ Android license status unknown., and of course running flutter doctor --android-licenses produces an error:

Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: <sdk>/cmdline-tools/latest/

How are the licenses handled? I knew with previous iterations of using the android SDK with flutter, the license was a read-only nix path, and could not easily be accepted deterministically. How do you accomplish this with this library?

Thank you

Unable to recognize NDK (and Gradle?)

Hello! I'm seeing an issue in the use of the NDK package.
I'm inexperienced in Android and a beginner in Nix; apologies on any simple errors I make.

I am running nix-shell android.nix --run android-studio; here's android.nix:

{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
  android-nixpkgs = callPackage <android-nixpkgs> { };
  android-sdk = android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
    cmdline-tools-latest
    build-tools-34-0-0
    platform-tools
    platforms-android-34
    emulator
    ndk-21-4-7075529
  ]);
in mkShell { buildInputs = [ android-studio android-sdk gradle ]; }

To begin, I had an error for a while regarding an unrecognized gradle;
I had to change my distributionUrl inside gradle-wrapper.properties to use 8.4.

distributionUrl=https://services.gradle.org/distributions/gradle-8.4-bin.zip

Once I do this, gradlew pulls a copy of gradle rather than using the one I asked for in android.nix.
Only a minor issue I guess.

My bigger problem is that the NDK is also unrecognized, and android has less luck pulling the missing copy to the read-only /nix/store.

Failed to install the following SDK components:
    ndk;21.4.7075529 NDK (Side by side) 21.4.7075529
The SDK directory is not writable (/nix/store/8vgf0v69gmkgyaxbvfs58rp9pfw6xdx5-android-sdk-env/share/android-sdk)

Maybe the problem is in the example app I am using - since no one else has opened these issues.
I'm using https://github.com/elixir-desktop/android-example-app and only changed the line inside gradle-wrapper.properties as described earlier.

I hope someone can lend a couple hands and a keyboard to help me launch to Android again.

This same app had been surprisingly easy to build on Fedora, and I'd been eager to add mobile apps to my arsenal. Seems like the Android onboarding experience has had large upgrades in prior years, though on NixOS there remains a need to build from square one. Hope this issue helps more people use the NDK seamlessly.

Trying to extend with flutter, but sdk issues are reported

Hi,

great project. I'm trying to base a flutter devshell on top, by extending the packages list with flutter. First thing usually run then is a flutter doctor, which checks the environment.

`[✓] Flutter (Channel stable, 3.10.5, on NixOS 23.05 (Stoat) 6.1.38, locale en_US.UTF-8)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop

[!] Android Studio (version 2022.2)
✗ Failed to run Java: ProcessException: No such file or directory
Command:
/nix/store/j8w0032qbyz6951mb6z2fp7nvm0976hy-android-studio-stable-2022.2.1.20-unwrapped/jbr/bin
/java -version
✗ Unable to determine bundled Java version.

[✓] Connected device (1 available)

[✓] Network resources
`

So I have basically two issues with the android-sdk setup, flutter reports:

the license status, but running the proposed command results in
Android sdkmanager tool was found, but failed to run (/nix/store/6ibjrsqxw5x4yrhyq04j9n1r4wz0q1yb-android-sdk-env/share/android-sdk/cmdline-tools/latest/bin /sdkmanager): "exited code 1". Try re-installing or updating your Android SDK, visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.
which seems rather an sdk setup issue.

For the second one, java is not found in the given path for android studio. Running it directly in the devshell works though.

Would be great to get some thoughts or hints, happy to fiddle around with the setup.
THX

android-studie + sdk fails, SDK missing or out of date

When using the default shell provided in the repo (without flakes), opening Android Studio gives the following error.

image

The path is correct to the SDK, and it seems to have all the things needed included. However, it ONLY works if the SDK is moved outside the nix store, and made RW. I can see that it changes one file, between the one in the store (android-sdk RO) and the one outside the store (android-sdk2 RW), and then it works.

$ diff --recursive android-sdk android-sdk2
diff '--color=auto' --recursive android-sdk/.knownPackages android-sdk2/.knownPackages
1c1
< ^���o6��[0m
\ No newline at end of file
---
> �(1h?E��
\ No newline at end of file
> xxd android-sdk/.knownPackages
00000000: 9a5e f119 dbe3 f179 ab6f 3698 17e0 d8dd  .^.....y.o6.....
> xxd android-sdk2/.knownPackages
00000000: effb 2831 683f b98a 45d4 e0cc d0a4 9894  ..(1h?..E.......

I'm not sure what the issue is, but I'm somewhat amazed that no issues have been made for it yet.

undefined variable mkDevShell

Hi,

I am trying to set up an Android dev environment in a flake-enabled NixOS system.

Following the readme, after nix flake init -t github:tadfisher/android-nixpkgs when I try to nix develop I am getting this error

error: undefined variable 'mkDevShell'

       at /nix/store/35300sdz5scln785w8cvv30b2lng77hn-source/devshell.nix:8:1:

            7| # Documentation: https://github.com/numtide/devshell
            8| mkDevShell {
             | ^
            9|   name = **"android-project"**```

Emulator crashes in Android Studio due to invalid SDK root

I am not able to run the Android Virtual Device emulator from Android Studio 2022.3.1.

The emulator crashes with message Cannot find valid sdk root path.

The emulator appears to be looking for the sdk root in /nix/store judging from the output of the crash log below.

what am I missing?

Steps to Reproduce

  1. add android-nixpkgs to nixos machine via home-manager module below.
  2. launch android-studio.
  3. provide SDK Location: File -> Project Structure -> SDK Location -> enter /home/$USER/Android/Sdk.
  4. add AVD: Tools -> Device Manager -> Create Device -> follow instructions to create Pixel_5_API_34 device.
  5. launch emulator.
  6. observe crash log output below in /home/$USER/.cache/Google/AndroidStudio2022.3/log/idea.log.

Failed Attempts to Fix

  1. make local.properties read only and removing sdk.path value in the file per FAQ section.
  2. Remove "Android SDK" element from ~/.config/Google/AndroidStudio{Version}/options/jdk.table.xml per FAQ section.
  3. Set ANDROID_HOME and ANDROID_SDK_HOME environment variables to /home/$USER/Android/Sdk via the Android Studio terminal and .bashrc.

Android Studio Crash Log

INFO - #com.android.tools.idea.devicemanager.DeviceManagerAndroidDebugBridge - []
INFO - #com.android.sdklib.internal.avd.AvdManager - /home/$USER/.android/avd/Pixel_5_API_34.avd/hardware-qemu.ini.lock not found for Pixel_5_API_34
INFO - #com.android.sdklib.internal.avd.AvdManager - /home/$USER/.android/avd/Pixel_5_API_34.avd/userdata-qemu.img.lock not found for Pixel_5_API_34
WARN - #com.android.tools.idea.avdmanager.AvdManagerConnection - Unable to determine if Pixel_5_API_34 is online, assuming it's not
INFO - Emulator: Pixel 5 API 34 - /home/$USER/Android/Sdk/emulator/emulator -netdelay none -netspeed full -avd Pixel_5_API_34 -qt-hide-window -grpc-use-token -idle-grpc-timeout 300
INFO - Emulator: Pixel 5 API 34 - Storing crashdata in: /tmp/android-$USER/emu-crash-34.1.12.db, detection enabled for process: 21252
WARN - Emulator: Pixel 5 API 34 - ANDROID_SDK_ROOT is missing.
INFO - Emulator: Pixel 5 API 34 - Android emulator version 34.1.12.0 (build_id 11146273) (CL:N/A)
INFO - Emulator: Pixel 5 API 34 - checking ANDROID_HOME for valid sdk root.
WARN - Emulator: Pixel 5 API 34 - platforms subdirectory is missing under /nix/store, please install it
INFO - Emulator: Pixel 5 API 34 - checking ANDROID_SDK_ROOT for valid sdk root.
INFO - Emulator: Pixel 5 API 34 - emulator: WARN: Cannot find valid sdk root from environment variable ANDROID_HOME nor ANDROID_SDK_ROOT,Try to infer from emulator's path
WARN - Emulator: Pixel 5 API 34 - platforms subdirectory is missing under /nix, please install it
INFO - Emulator: Pixel 5 API 34 - guessed sdk root is /nix/store
WARN - Emulator: Pixel 5 API 34 - platforms subdirectory is missing under /, please install it
INFO - Emulator: Pixel 5 API 34 - guessed sdk root /nix/store does not seem to be valid
INFO - Emulator: Pixel 5 API 34 - guessed sdk root is /nix
WARN - Emulator: Pixel 5 API 34 - invalid sdk root /
INFO - Emulator: Pixel 5 API 34 - guessed sdk root /nix does not seem to be valid
INFO - Emulator: Pixel 5 API 34 - guessed sdk root is /
INFO - Emulator: Pixel 5 API 34 - PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
INFO - Emulator: Pixel 5 API 34 - guessed sdk root / does not seem to be valid
INFO - Emulator: Pixel 5 API 34 - emulator: WARN: Cannot find valid sdk root path.
INFO - Emulator: Pixel 5 API 34 - Process finished with exit code 1
SEVERE - Emulator: Pixel 5 API 34 - Emulator terminated with exit code 1

android-sdk.nix

{ config, pkgs, lib, android-nixpkgs, system, inputs, ... }:

{
	imports = [ inputs.android-nixpkgs.hmModule ];
	
	nixpkgs.overlays = [ inputs.android-nixpkgs.overlays.default ];

	android-sdk.enable = true;

	# Optional; default path is "~/.local/share/android".
	android-sdk.path = "${config.home.homeDirectory}/Android/Sdk";

	android-sdk.packages = sdk: with sdk; [
	  build-tools-34-0-0-rc3
	  cmdline-tools-latest
	  emulator
	  platform-tools
	  platforms-android-34
	  sources-android-34
	  system-images-android-34-google-apis-x86-64
	];

}

Readme incomplete (Home manager & flakes)

I tried installing via home manager and flakes and I got:

error: anonymous function at /nix/store/809567g3ws9r3lpjahn8l1wfp6bk1r9w-source/hm-module.nix:1:1 called without required argument 'lib'

       at /nix/store/mr47zm8r481wv7nakgds1j4rpqnwkj9b-source/specific/SB-1361/home.nix:5:17:

            4| let
            5|   android-sdk = android-nixpkgs.hmModule {
             |                 ^
            6|     android-sdk.enable = true;
(use '--show-trace' to show detailed location information)

I could fix it by adding:

    inherit pkgs config lib;

Incorrect ANDROID_HOME value

When generating with config (i.e. default)

path = "${home.xdg.dataHome}/android";

Then files are correctly placed at $XDG_DATA_HOME/android (for example /home/foo/.local/share/android), but the environment variables have incorrect values:

ANDROID_HOME=.local/share/android
ANDROID_SDK_ROOT=.local/share/android

Note how the values use a path relative to $HOME instead of a full path, so they don't work in most places where they are used.

This happens because of this:

ANDROID_HOME = config.home.file.${cfg.path}.target;
ANDROID_SDK_ROOT = config.home.file.${cfg.path}.target;

From home-manager's documentation on home.file.<name>.target:

Path to target file relative to HOME.

(Emphasis mine)


I am unable to override this in my own config since I get collisions. Is there some other way I can fix this?


I suggest we just set the variables to cfg.path directly.

error: attribute 'androidSdk' missing

i trying to install with flake and darwin config, when execute nix build ".darwinconfiguration.name.system" nix throw this error

warning: Git tree '/Users/myhome/.config/nixpkgs' is dirty
error: attribute 'androidSdk' missing

       at /nix/store/wy0fqvif182vashfqdgciqa7w8n36fml-source/hm-module.nix:48:32:

           47|   config = mkIf (cfg.enable) {
           48|     android-sdk.finalPackage = pkgs.androidSdk cfg.packages;
             |                                ^
           49|
(use '--show-trace' to show detailed location information)

Missing libcryptx-legacy

I tried to run the following nix file from the readme

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

let
  android-nixpkgs = callPackage <android-nixpkgs> {
    # Default; can also choose "beta", "preview", or "canary".
    channel = "stable";
  };

in
android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
  cmdline-tools-latest
  build-tools-32-0-0
  platform-tools
  platforms-android-31
  emulator
])

then

nix-shell sdk.nix

but I get the error:

error: assertion '((stdenv).isLinux -> (libxcrypt-legacy != null))' failed

       at /nix/store/9slbnzb9kbrval7xj72l7mbwqmrlgz69-android-nixpkgs/android-nixpkgs/pkgs/android/ndk.nix:17:1:

           16| assert stdenv.isLinux -> autoPatchelfHook != null;
           17| assert stdenv.isLinux -> libxcrypt-legacy != null;
             | ^
           18| assert stdenv.isLinux -> ncurses5 != null;
(use '--show-trace' to show detailed location information)

I tried to install the libxcrypt package but that did not help

Setting NDK_HOME

My app needs $NDK_HOME to work, but I can't seem to find the path. Where do I find it?

Ancient version of java packaged is incompatible with avdmanager

This is on an M1 Macbook Air:

$ nix develop
Entered the Android app development environment.

$ which java
/nix/store/d2lwgrxcv0b5wgfj9p7c5mpld55l7k5v-devshell-dir/bin/java
$ java -version
openjdk version "11.0.22" 2024-01-16 LTS
OpenJDK Runtime Environment Zulu11.70+15-CA (build 11.0.22+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.70+15-CA (build 11.0.22+7-LTS, mixed mode)
$ avdmanager
Error: LinkageError occurred while loading main class com.android.sdklib.tool.AvdManagerCli
	java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/AvdManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

d8 wrapper scripts hardcodes reference to /bin/ls

Running d8 from the build-tools package gives me:

/nix/store/nsnsy63z4i882kqp7nfym6859zhcv0h2-android-sdk-env/share/android-sdk/build-tools/31.0.0/d8 --lib /nix/store/nsnsy63z4i882kqp7nfym6859zhcv0h2-android-sdk-env/share/android-sdk/platforms/android-31/android.jar --output /tmp/nix-shell.K0Xopm/gogio-3224717364/apk --min-api 16 /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/Gio$1.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/Gio.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioActivity.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$1.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$2.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$3.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$4.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$Bar.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$GioInputConnection.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView$Snippet.class /tmp/nix-shell.K0Xopm/gogio-3224717364/classes/org/gioui/GioView.class failed: 31.0.0: can't find d8.jar
/nix/store/nsnsy63z4i882kqp7nfym6859zhcv0h2-android-sdk-env/share/android-sdk/build-tools/31.0.0/d8: line 21: /bin/ls: No such file or directory

because of a hardcoded reference to /bin/ls in d8's wrapper script:

...
# Set up prog to be the path of this script, including following symlinks,
# and set up progdir to be the fully-qualified pathname of its directory.
prog="$0"
while [ -h "${prog}" ]; do
    newProg=`/bin/ls -ld "${prog}"`
    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
    if expr "x${newProg}" : 'x/' >/dev/null; then
        prog="${newProg}"
    else
        progdir=`dirname "${prog}"`
        prog="${progdir}/${newProg}"
    fi
done
...

I'm still new to Nix so I'm unsure how to fix it. I'll send a PR if I figure it out.

[Feature request] Create Nix packages for the packages required to run the Cuttlefish virtual device

Currently, running the launch_cvd command after compiling AOSP for a Cuttlefish-supported lunch target results in the following error:

sh: line 1: /usr/lib/cuttlefish-common/bin/capability_query.py: No such file or directory
VM manager crosvm is not supported on this machine.
Invalid vm_manager: crosvm
E launch_cvd: subprocess.cpp:198 Subprocess 1628684 was interrupted by a signal 'Aborted' (6)
E launch_cvd: main.cc:436 assemble_cvd returned -1

The Cuttlefish virtual device requires a number of (Debian) host packages, listed here: https://github.com/google/android-cuttlefish

It looks like cuttlefish-base and cuttlefish-user are all that are directly used when running Cuttlefish locally.

This is also required if acloud were to be packaged later using Nix as well.

Improve documentation on simultaneous usage of `cmdline-tools-latest` and `tools`

Hi, first of all, I'd like to express my thanks for the great work in this package set.

When I first used cmdline-tools-latest with this package set to build my project, apparently some dependencies also demanded the presence of a tools installation as well.

If one includes both cmdline-tools-latest and tools, care must be taken to put cmdline-tools-latest after tools in the list of requested sdk packages. This is due to some binaries with the same name being present in both cmdline-tools-latest and tools. The binary version listed later will be effective in the outputs provided to $PATH.

The old tools version does not pass all the flags to find android sdk roots, and thus will cause the sdk package to exhibit symptoms such as avdmanager hanging on "Loading local repository..." and emulator hanging similarly.

I think this should be better documented, and would've saved me several hours of time.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.