I’m having immense trouble with this. I don’t know the correct syntax for accepting the terms for the Android SDK. The error I get is this:
" ```
You must accept the following licenses:
- android-sdk-license
a)
by setting nixpkgs config option ‘android_sdk.accept_license = true;’.
b)
by an environment variable for a single invocation of the nix tools.
$ export NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE=1
I've tried pretty much every conceivable way of writing license=true in the dev.nix file, but it just doesn't work. Can anyone assist?
I’m having the team look into this right now. Just to double-check, you both created new projects in Firebase Studio. If you were to create a new project again now, does the error keep happening?
Thanks for looking into this, I appreciate the quick response!
In my case, I’m opening an existing github repo, but I’m not sure if this really matters, since this is an environment problem. I’m getting the following error as soon as I try to open the project.
One thing you can try is mimicking the dev.nix we use for a typical Flutter project and seeing if that starting point helps get your project into a working state. Here is the dev.nix file for a (working) new Flutter project I just created:
# To learn more about how to use Nix to configure your environment
# see: https://firebase.google.com/docs/studio/customize-workspace
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-24.05"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.jdk17
pkgs.unzip
];
# Sets environment variables in the workspace
env = {};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
extensions = [
"Dart-Code.flutter"
"Dart-Code.dart-code"
];
workspace = {
# Runs when a workspace is first created with this `dev.nix` file
onCreate = {
build-flutter = ''
cd /home/user/myapp/android
./gradlew \
--parallel \
-Pverbose=true \
-Ptarget-platform=android-x86 \
-Ptarget=/home/user/myapp/lib/main.dart \
-Pbase-application-name=android.app.Application \
-Pdart-defines=RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC85NzU1MDkwN2I3MGY0ZjNiMzI4YjZjMTYwMGRmMjFmYWMxYTE4ODlhLw== \
-Pdart-obfuscation=false \
-Ptrack-widget-creation=true \
-Ptree-shake-icons=false \
-Pfilesystem-scheme=org-dartlang-root \
assembleDebug
# TODO: Execute web build in debug mode.
# flutter run does this transparently either way
# https://github.com/flutter/flutter/issues/96283#issuecomment-1144750411
# flutter build web --profile --dart-define=Dart2jsOptimization=O0
'';
};
# To run something each time the workspace is (re)started, use the `onStart` hook
};
# Enable previews and customize configuration
previews = {
enable = true;
previews = {
web = {
command = ["flutter" "run" "--machine" "-d" "web-server" "--web-hostname" "0.0.0.0" "--web-port" "$PORT"];
manager = "flutter";
};
android = {
command = ["flutter" "run" "--machine" "-d" "android" "-d" "localhost:5555"];
manager = "flutter";
};
};
};
};
}
This is the current dev.nix file I’m using. It’s the default one, except the android packages & the suggested syntax for accepting the license:
# To learn more about how to use Nix to configure your environment
# see: https://firebase.google.com/docs/studio/customize-workspace
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-24.11"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = [
# pkgs.go
# pkgs.python311
# pkgs.python311Packages.pip
# pkgs.nodejs_20
# pkgs.nodePackages.nodemon
pkgs.android-studio.override {android_sdk.accept_license = true;}
pkgs.android-studio-tools
];
# Sets environment variables in the workspace
env = {
ANDROID_HOME = "${pkgs.androidsdk}";
NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE= "1";
};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
extensions = [
# "vscodevim.vim"
];
# Enable previews
previews = {
enable = true;
previews = {
# web = {
# # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
# # and show it in IDX's web preview panel
# command = ["npm" "run" "dev"];
# manager = "web";
# env = {
# # Environment variables to set for your server
# PORT = "$PORT";
# };
# };
};
};
# Workspace lifecycle hooks
workspace = {
# Runs when a workspace is first created
onCreate = {
# Example: install JS dependencies from NPM
# npm-install = "npm install";
};
# Runs when the workspace is (re)started
onStart = {
# Example: start a background task to watch and re-build backend code
# watch-backend = "npm run watch-backend";
};
};
};
}