我有现有的Android应用程序,我想在切换到NixOS后继续构建。
根据Nixpkgs手册中的描述,我遵循了几条基本上始终遵循的说明:https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md
我遇到的问题是: 当我用这样的东西构建自己的环境时:
with import <nixpkgs> {};
let
androidComposition = androidenv.composeAndroidPackages {
toolsVersion = "25.2.5";
platformToolsVersion = "27.0.1";
buildToolsVersions = [ "27.0.3" ];
includeEmulator = false;
emulatorVersion = "27.2.0";
platformVersions = [ "24" ];
includeSources = false;
includeDocs = false;
includeSystemImages = false;
systemImageTypes = [ "default" ];
abiVersions = [ "armeabi-v7a" ];
lldbVersions = [ "2.0.2558144" ];
cmakeVersions = [ "3.6.4111459" ];
includeNDK = false;
ndkVersion = "16.1.4479499";
useGoogleAPIs = false;
useGoogleTVAddOns = false;
includeExtras = [
"extras;google;gcm"
];
};
in
androidComposition.androidsdk
然后,没有定义环境变量ANDROID_HOME,并且调用项目的gradlew
将不会抱怨。如果我尝试找到可以手动将ANDROID_HOME定向到的地方,那么我将失败,因为gradle版本会抱怨我不接受SDK的许可协议。 (而且我也不能接受许可证,因为我必须在只读nix存储区中这样做。)
我还尝试使用Nix构建具有以下功能的完整应用程序:
with import <nixpkgs> {};
androidenv.buildApp {
name = "Tove";
src = ./tove;
release = true;
keyStore = ./tove/release.keystore;
keyAlias = "ReleaseKey";
keyStorePassword = "XXXXXXXX";
keyAliasPassword = "XXXXXXXX";
platformVersions = [ "28" ];
includeNDK = false;
}
但是在我看来,这仅支持基于Ant的构建。但是我无法将完整的构建环境更改为Ant,因为那时我的同事会抱怨。在这种情况下,我得到的错误是:
these derivations will be built:
/nix/store/1pnd3zra0p6q2w4nij8mp49b1jr6g0p2-Tove.drv
building '/nix/store/1pnd3zra0p6q2w4nij8mp49b1jr6g0p2-Tove.drv'...
unpacking sources
unpacking source archive /nix/store/l1lphdp98cxfhq5dahr63ipjrz9qbn6l-tove
source root is tove
patching sources
configuring
no configure script, doing nothing
building
Buildfile: build.xml does not exist!
Build failed
builder for '/nix/store/1pnd3zra0p6q2w4nij8mp49b1jr6g0p2-Tove.drv' failed with exit code 1
error: build of '/nix/store/1pnd3zra0p6q2w4nij8mp49b1jr6g0p2-Tove.drv' failed
我如何获得一个可以在NixOS内使用gradle构建Android应用程序的环境?有帮助或教程吗?