The Syntax Chronicles: Solution for Flutter Doctor and Android Studio detection on macOS

When Flutter finds neither Android Studio nor Java

Crafted Codes
Women in Technology
2 min readJan 26, 2024

--

MidJourney generated image — Dieser Artikel ist auch auf Deutsch erhältlich

Even long-standing Flutter installations on macOS can sometimes suddenly become buggy, especially if Flutter Doctor suddenly stops recognising Android Studio (as happened to me recently). This guide offers you a solution to solve exactly these problems.

Identification of the problem

Our diagnosis shows that Flutter Doctor has difficulties identifying the installed version of Android Studio and the corresponding Java version. This can occur in particular with parallel installations, such as the preview version of Android Studio.

It may be that, as in my case, Android Studio Preview.app can be in iCloud Drive (Archiv)/Desktop/. Then move the file to the Applications folder.

Adaptation of the environment variables

The solution requires an adjustment of the environment variables in the .zshrc file:

  1. Open the terminal and edit the .zshrc file with nano ~/.zshrc.
  2. Add the necessary export commands at the end of the file to define the paths to Android Studio and Java:
export ANDROID_STUDIO_PATH="/Applications/Android Studio.app"
export PATH="$PATH:$ANDROID_STUDIO_PATH/bin"
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"

3. Save and close the file with Ctrl + O and Ctrl + X, and run source ~/.zshrc to load the changes (I also restarted the terminal).

Solution for duplicate Android Studio versions

If Flutter Doctor reports problems due to an existing preview version of Android Studio, there are two possibilities:

  1. Uninstalling the Android Studio Preview version: Drag /Applications/Android Studio Preview.app to the trash if this version is not needed.
  2. Resetting the Flutter configuration for Android Studio: If you want to keep the preview version, run the following command suggested by Flutter to reset the android-studio-dir setting:
flutter config --android-studio-dir=

Checking the corrections

Run flutter doctor to check whether the problems have been resolved. If Flutter Doctor no longer displays any errors, your development environment is fully operational again.

Final recommendations

I recommend that you use a single version of Android Studio to avoid conflicts, unless of course it cannot be avoided.

By following these steps, you have successfully overcome the challenges of a sudden Flutter Doctor malfunction and stabilised your development environment.

--

--