Flutter: Difference between revisions
m Bump NixOS input version. |
m Fix typo androidsdk -> androidSdk |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 8: | Line 8: | ||
To build Flutter apps to Linux desktop or Web you only need the <code>flutter</code> package from Nixpkgs. | To build Flutter apps to Linux desktop or Web you only need the <code>flutter</code> package from Nixpkgs. | ||
Then run <code>flutter build linux</code> or <code>flutter build web</code>. | Then run <code>flutter build linux</code> or <code>flutter build web</code>. Ensure that <code>pkg-config</code> is installed on your system, either through a development shell or directly on the base system. Not having <code>pkg-config</code> available may result in compilation errors. | ||
=== Android === | === Android === | ||
Line 22: | Line 22: | ||
description = "Flutter 3.13.x"; | description = "Flutter 3.13.x"; | ||
inputs = { | inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/24.11"; | nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | flake-utils.url = "github:numtide/flake-utils"; | ||
}; | }; | ||
Line 84: | Line 84: | ||
buildInputs = [ | buildInputs = [ | ||
flutter | flutter | ||
androidSdk | |||
jdk17 | jdk17 | ||
]; | ]; | ||
Line 108: | Line 108: | ||
Use [https://github.com/NixOS/nixpkgs/blob/cfe96dbfce8bd62dcd4a8ad62cb79dec140b1a62/pkgs/development/compilers/flutter/flutter.nix#L168 buildFlutterApplication from nixpkgs]. | Use [https://github.com/NixOS/nixpkgs/blob/cfe96dbfce8bd62dcd4a8ad62cb79dec140b1a62/pkgs/development/compilers/flutter/flutter.nix#L168 buildFlutterApplication from nixpkgs]. | ||
== Troubleshooting == | |||
* The default Gradle template for android captures the Android and Flutter SDK paths in <code>android/local.properties</code> preventing future updates to the SDK from participating in the build. This manifests itself as Gradle failing to install SDK components registered in the shell. To fix, simply delete the properties file and run the build again.<syntaxhighlight lang="shell-session">FAILURE: Build failed with an exception. | |||
* Where: | |||
Build file /xxx/android/build.gradle.kts' line: 16 | |||
* What went wrong: | |||
A problem occurred configuring project ':app'. | |||
> com.android.builder.sdk.InstallFailedException: Failed to install the following SDK components: | |||
ndk;26.3.11579264 NDK (Side by side) 26.3.11579264 | |||
The SDK directory is not writable (/nix/store/1xw5npxd7isrl50pl7y82anhdapnfs6p-androidsdk/libexec/android-sdk)</syntaxhighlight>Alternatively, adjust <code>composeAndroidPackages</code> to include the exact version of the SDK components flutter requires. In the example above, simply add the <code>ndkVersion</code> as in the example below. | |||
{{Code|1=... | |||
androidComposition = pkgs.androidenv.composeAndroidPackages { | |||
... | |||
ndkVersions = [ "26.3.11579264" ] | |||
... | |||
}; | |||
...}} | |||
== See also == | == See also == |