I’d like to build the Android app ‘Alarmio’.
Following NixOS - Nixpkgs 21.05 manual, I created a shell.nix
:
{ pkgs ? import <nixpkgs> {} }:
pkgs.androidenv..buildApp {
name = "Alarmio";
platformVersions = [ "28" ];
}
This gave me a
$ nix-shell
error: You must accept the Android Software Development Kit License Agreement at
https://developer.android.com/studio/terms
by setting nixpkgs config option 'android_sdk.accept_license = true;'
(use '--show-trace' to show detailed location information)
even though I do have nixpkgs.config.android_sdk.accept_license = true
in my /etc/nixos/configuration.nix
. I guess licenseAccepted
isn’t passed on correctly somewhere? Anyway I ‘hacked around’ it like:
{ pkgs ? import <nixpkgs> {} }:
(pkgs.androidenv.override {
licenseAccepted = true;
})
.buildApp {
name = "Alarmio";
platformVersions = [ "28" ];
}
This allows me to enter the nix-shell, but then when I try to ./gradlew install
I get:
FAILURE: Build completed with 4 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeOssDebugResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.0-5435860-linux Daemon #20: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Adding --stacktrace
reveals /home/aengelen/.gradle/caches/transforms-2/files-2.1/8848e96d59858a36a941eba86940e0ae/aapt2-3.5.0-5435860-linux/aapt2
cannot be executed. Indeed, running that executable directly, it doesn’t have the interpreter set. I can patchelf
the correct interpreter, but it seems gradle overwrites it every time.
Any ideas on how to get over this hurdle?