I am trying to create a devshell flake for a flutter environment, I wanted to use devshells to take advantage of Nix’s power but I am encountering some issues.
I have the appropriate packages defined and also the environment variables so that the emulator can see the AVD that was created but whenever I try to run the flutter app on the AVD I get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/zander/Nextcloud/Projects/Applications/bookshelf/android/build.gradle.kts' line: 16
* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.sdk.LicenceNotAcceptedException: Failed to install the following Android SDK packages as some licences have not been accepted.
ndk;26.3.11579264 NDK (Side by side) 26.3.11579264
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
All licenses can be accepted using the sdkmanager command line tool:
sdkmanager.bat --licenses
Or, to transfer the license agreements from one workstation to another, see https://developer.android.com/studio/intro/update.html#download-with-gradle
Using Android SDK: /nix/store/yqk2048cmf27b16al6d2b08j4qqk0pac-android-sdk-platform-tools-35.0.2/libexec/android-sdk
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 2s
Running Gradle task 'assembleDebug'... 4.6s
Error: Gradle task assembleDebug failed with exit code 1
I also have the android_sdk.accept_license = true enabled in my flake. So I did sdkmanager --licenses and accepted all the licenses that I haven’t accepted yet, of which there were 6 of 7. After saying yes to all of them it still says I haven’t accepted them. I did noticed the warnings are a bit weird but I have set the ANDROID_NDK_HOME to be the right location in the nixpkgs.androidsdk path.
Warning: Observed package id 'ndk;28.1.13356709' in inconsistent location '/nix/store/ivh1jgqjy3iz0829nf41hv5p9mmhn3fn-androidsdk/libexec/android-sdk/ndk-bundle' (Expected '/nix/store/ivh1jgqjy3iz0829nf41hv5p9mmhn3fn-androidsdk/libexec/android-sdk/ndk/28.1.13356709')
Warning: Observed package id 'ndk;28.1.13356709' in inconsistent location '/nix/store/ivh1jgqjy3iz0829nf41hv5p9mmhn3fn-androidsdk/libexec/android-sdk/ndk-bundle' (Expected '/nix/store/ivh1jgqjy3iz0829nf41hv5p9mmhn3fn-androidsdk/libexec/android-sdk/ndk/28.1.13356709')
[=======================================] 100% Computing updates...
6 of 7 SDK package licenses not accepted.
Review licenses that have not been accepted (y/N)?
Here is my flake.nix
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
system = system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
};
android_home = "${pkgs.androidsdk}/libexec/android-sdk";
in
{
androidEnv = pkgs.androidenv.override { licenseAccepted = true; };
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
flutter
android-tools
androidenv.androidPkgs.androidsdk
androidenv.androidPkgs.ndk-bundle
openjdk
];
ANDROID_HOME = "${android_home}";
# ANDROID_SDK_ROOT = "${android_home}";
ANDROID_NDK_HOME = "${android_home}/ndk";
ANDROID_AVD_HOME = "/home/zander/.config/.android/avd";
shellHook = ''
echo $ANDROID_AVD_HOME
exec ${pkgs.zsh}/bin/zsh
'';
};
};
}
I’m pretty new to nix and this is my first time settings up a devshell so I could be missing something very obvious here. Any help would be greatly appreciated