Jump to content

Flutter

From NixOS Wiki
Revision as of 11:22, 12 October 2025 by Username-Generic (talk | contribs) (Added a new Troubleshooting entry regarding `ANDROID_HOME`)

Troubleshooting

  • The default Gradle template for android captures the Android and Flutter SDK paths in android/local.properties preventing future updates to the SDK from participating in the build. Example:
    $ 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
    
    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 android/local.properties achieves nothing.
    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)
    
  • There might be cases where setting the ANDROID_HOME 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 ($XDG_CONFIG_HOME/settings or $XDG_CONFIG_HOME/flutter/settings) containing an incorrectly set "android-sdk" key-value pair. Once removed, the environment variable should no longer be overridden, and should function correctly.