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:
|
|
Our final structure should look like this:
|
|
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):
|
|
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:
|
|
You will see message to link the JDK, follow the instructions to add it to your PATH. For example:
|
|
Don’t forget to set the JAVA_HOME environment variable as well:
|
|
Verify java installation by using the command:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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!