Flutter - Android SDK Folder Not Writable (Temporary Problem Solved

If this problem persists, try the following steps:

  1. Create an Android SDK directory:

mkdir -p ~/android-sdk

  1. Copy all files from the previous Android SDK:

Replace /nix/store/0wqd5nfc2hlx13davkvq2zf3zcy0wr61-androidsdk/libexec/android-sdk/ with the path to your existing Android SDK directory (you can find this in your error log). Then run:

cp -r /nix/store/0wqd5nfc2hlx13davkvq2zf3zcy0wr61-androidsdk/libexec/android-sdk/* ~/android-sdk/

  1. Configure the new directory as the Flutter Android SDK:

flutter config --android-sdk ~/android-sdk

  1. Add the path variable in Nix:
    Set the ANDROID_SDK_ROOT environment variable:

export ANDROID_SDK_ROOT=~/android-sdk

  1. Make it persistent:
    Append the environment variable to your ~/.bashrc file:

echo "export ANDROID_SDK_ROOT=~/android-sdk" >> ~/.bashrc

source ~/.bashrc

  1. Grant read and write permissions:

chmod -R 755 ~/android-sdk

  1. Done!

Now, run the Flutter build command:

flutter build

6 Likes

so what if the problem is fixed how do reverse the changes made, and use the nix store adriod sdk

1 Like

Don’t do anything more for this. Just run the following command:
flutter config --android-sdk /nix/store/0wqd5nfc2hlx13davkvq2zf3zcy0wr61-androidsdk/libexec/android-sdk/* ~/android-sdk/

2 Likes

is this code for fixing or reversing the changes?

1 Like

To delete the newly created Android SDK directory, use the following command:
rm -rf ~/android-sdk

2 Likes

hightechsgyan its working thank you very much thats work

2 Likes

It works, thank you very much @hightechsgyan

1 Like

Thanks a lot. It worked. Grateful <3

Now i’m getting this error.

2025-01-25T17:57:34Z [android] Flutter daemon started
2025-01-25T17:57:35Z [android] Launching lib/main.dart on sdk gphone64 x86 64 in debug mode…
2025-01-25T17:57:36Z [android] Running Gradle task ‘assembleDebug’…
2025-01-25T17:58:19Z [android] Checking the license for package Android SDK Build-Tools 33.0.1 in /home/user/android-sdk/licenses
2025-01-25T17:58:19Z [android] Warning: License for package Android SDK Build-Tools 33.0.1 not accepted.
2025-01-25T17:58:19Z [android] Checking the license for package Android SDK Platform 34 in /home/user/android-sdk/licenses
2025-01-25T17:58:19Z [android] Warning: License for package Android SDK Platform 34 not accepted.
2025-01-25T17:58:19Z [android] Error:
2025-01-25T17:58:19Z [android]
2025-01-25T17:58:19Z [android] Error: FAILURE: Build failed with an exception.
2025-01-25T17:58:19Z [android]
2025-01-25T17:58:19Z [android] * What went wrong:
2025-01-25T17:58:19Z [android] Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac’.
2025-01-25T17:58:19Z [android]
2025-01-25T17:58:19Z [android] Error: > Failed to install the following Android SDK packages as some licences have not been accepted.
2025-01-25T17:58:19Z [android] platforms;android-34 Android SDK Platform 34
2025-01-25T17:58:19Z [android]
2025-01-25T17:58:19Z [android] Error: build-tools;33.0.1 Android SDK Build-Tools 33.0.1
2025-01-25T17:58:19Z [android] To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
2025-01-25T17:58:19Z [android] All licenses can be accepted using the sdkmanager command line tool:
2025-01-25T17:58:19Z [android] sdkmanager.bat --licenses
2025-01-25T17:58:19Z [android] Or, to transfer the license agreements from one workstation to another, see Update the IDE and SDK tools  |  Android Studio  |  Android Developers
2025-01-25T17:58:19Z [android]
2025-01-25T17:58:19Z [android] Using Android SDK: /home/user/android-sdk

You have to accept the android licenses since it a custom android sdk being used;
To resolve this, run: flutter doctor --android-licenses

@Idx.dev hasn’t the problem being fixed yet?

Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.

Is there anything I can do about this?

[✓] Flutter (Channel stable, 3.29.0, on IDX GNU/Linux 6.1.124+, locale en_US.UTF-8) [39ms]
    • Flutter version 3.29.0 on channel stable at /home/user/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35c388afb5 (11 days ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✗] Android toolchain - develop for Android devices [40ms]
    • Android SDK at /nix/store/w42qkfz3z0insr7z83402anmk1kjv0vn-android-sdk-platform-tools-34.0.5/libexec/android-sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) [21ms]
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✗] Linux toolchain - develop for Linux desktop [40ms]
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
    ✗ pkg-config is required for Linux development.
      It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/

[!] Android Studio (not installed) [19ms]
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).

[✓] Connected device (3 available) [146ms]
    • sdk gphone64 x86 64 (mobile) • emulator-5554  • android-x64 • Android 14 (API 34) (emulator)
    • sdk gphone64 x86 64 (mobile) • localhost:5555 • android-x64 • Android 14 (API 34) (emulator)
    • Linux (desktop)              • linux          • linux-x64   • IDX GNU/Linux 6.1.124+

[✓] Network resources [604ms]
    • All expected network resources are available.

I also had such a problem. The way to fix this is to recreate the project. Publish your flutter app on github. And on the idx main page, select “Import Repository”, paste your github repository URL, click on the “This is a flutter application” checkbox and click “Import”. Done this may solve this problem. It worked for me.