Featured image of post Develop Flutter Without Android Studio in Mac

Develop Flutter Without Android Studio in Mac

If you're like me and prefer a lightweight setup, you probably don’t want to install the full Android Studio just to run Flutter on a physical device. The good news? You don’t have to. In this guide, I’ll show you how to set up Flutter development on your Mac without the need for Android Studio, using only the command line and a few essential tools.

Installing Android Command Line Tools (Without Android Studio)

Step 1: Download the Android Command Line Tools

Head over to the Android Studio download page and scroll down to the “Command line tools only” section. Download the appropriate version for MacOS. Extract the downloaded zip file and you will get a folder named cmdline-tools.

Step 2: Move the Command Line Tools to a Proper Location

Let’s organize the command line tools in a way that Flutter can easily find them. Move the cmdline-tools folder to a location of your choice, for example:

1
2
mkdir -p ~/Android/cmdline-tools
mv ~/Downloads/cmdline-tools ~/Android/cmdline-tools/latest

Our final structure should look like this:

1
2
3
4
~/Android/cmdline-tools/
|____latest
| |____bin
| |____lib

Step 3: Set Environment Variables

To let Flutter know where the Android SDK is located, we need to set some environment variables. Open your terminal and add the following lines to your shell configuration file (e.g., ~/.zshrc or ~/bash_profile):

1
2
3
export ANDROID_HOME=$HOME/Android
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH

Step 4: Install Java Development Kit (JDK)

The Android command line tools require Java to run. For proper Flutter development, it’s recommended to install JDK 11 or later. You can download it from AdoptOpenJDK or use Homebrew:

1
brew install openjdk@11

You will see message to link the JDK, follow the instructions to add it to your PATH. For example:

1
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Don’t forget to set the JAVA_HOME environment variable as well:

1
2
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH

Verify java installation by using the command:

1
java -version

Step 5: Install required SDK Packages

Now, the important part: we need to install the necessary Android SDK packages to build and run Flutter apps. Use the following commands to install the required components:

1
2
3
4
sdkmanager --sdk_root=$ANDROID_HOME \
"platform-tools" \
"platforms;android-34" \
"build-tools;34.0.0"

We install android 34 with build-tools v34.0.0, but you can adjust the versions as needed. My recommendation use this version as it’s the latest stable release at the time of writing.

Step 6: Accept Licenses

Before you can use the Android SDK, you need to accept the licenses for the packages you just installed. Run the following command to accept all licenses:

1
sdkmanager --licenses --sdk_root=$ANDROID_HOME

Follow the prompts to accept each license agreement.

Step 7: Verify Flutter Can Find the Android SDK

Finally, let’s check if Flutter can detect the Android SDK. Run the following command:

1
flutter doctor

You should see that Flutter recognizes the Android toolchain and the Android SDK. If everything is set up correctly, you should see a message indicating that the Android toolchain is available and properly configured.

Bonus

Becuase I don’t want to create virtual devices for now, I will use my physical device for testing. To do that, I need to enable USB debugging on my Android phone and connect it to my Mac via USB. Once connected, run the following command to check if your device is recognized:

1
adb devices

Conclusion

And that’s it! You now have a fully functional Flutter development environment on your Mac without the need for Android Studio. This setup is lightweight and allows you to focus on building your Flutter apps without the overhead of a full IDE. Happy coding!

Built with Hugo
Theme Stack designed by Jimmy