Flutter: Difference between revisions

Bme (talk | contribs)
Clarifying the troubleshooting section: deleting the cached file is only important if shell changes aren't reflected in the build.
m Replaced `ANDROID_SDK_ROOT` with its non-deprecated counterpart
 
(4 intermediate revisions by 2 users not shown)
Line 46: Line 46:
       devShell =
       devShell =
         with pkgs; mkShell rec {
         with pkgs; mkShell rec {
           ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
           ANDROID_HOME = "${androidSdk}/libexec/android-sdk";
           buildInputs = [
           buildInputs = [
             flutter
             flutter
Line 81: Line 81:
       devShell =
       devShell =
         with pkgs; mkShell rec {
         with pkgs; mkShell rec {
           ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
           ANDROID_SDK = "${androidSdk}/libexec/android-sdk";
           buildInputs = [
           buildInputs = [
             flutter
             flutter
Line 111: Line 111:
== Troubleshooting ==
== 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. NOTE: this assumes that the shell correctly reflects the requirements of the build. If it doesn't correct that first, otherwise deleting <code>android/local.properties</code> achieves nothing.<syntaxhighlight lang="shell-session">FAILURE: Build failed with an exception.
* 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. Example:<syntaxhighlight lang="shell-session">$ cat android/local.properties
sdk.dir=/nix/store/m5ygjwkz8brwkw9anx9kbwssymwvlaxl-androidsdk/libexec/android-sdk
flutter.sdk=/nix/store/rga4z7r7x705lns431b89gwxx47zs1zp-flutter-wrapped-3.29.3-sdk-links
flutter.buildMode=debug
flutter.versionName=6.3.2</syntaxhighlight>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. NOTE: this assumes that the shell correctly reflects the requirements of the build. If it doesn't correct that first, otherwise deleting <code>android/local.properties</code> achieves nothing.<syntaxhighlight lang="shell-session">FAILURE: Build failed with an exception.


* Where:
* Where:
Line 121: Line 125:
       ndk;26.3.11579264 NDK (Side by side) 26.3.11579264
       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>
   The SDK directory is not writable (/nix/store/1xw5npxd7isrl50pl7y82anhdapnfs6p-androidsdk/libexec/android-sdk)</syntaxhighlight>
* There might be cases where setting the <code>ANDROID_HOME</code> environment variable will have no effect on Flutter's ability to assess the validity of Android SDK's installation. This behavior may be caused by an existing configuration file (<code>$XDG_CONFIG_HOME/settings</code> or <code>$XDG_CONFIG_HOME/flutter/settings</code>) containing an incorrectly set <code>"android-sdk"</code> key-value pair. Once removed, the environment variable should no longer be overridden, and should function correctly.
== See also ==
== See also ==