Skip to main content

Android Studio Setup for Flutter Development

Welcome to the complete guide on setting up Android Studio for Flutter development! Whether you’re new to mobile app development or a seasoned developer looking to get started with Flutter, this tutorial will walk you through every step you need to set up Android Studio, install the necessary plugins, create your first Flutter app, and run it successfully.

Android Studio is one of the most popular IDEs (Integrated Development Environments) developed by Google for building Android apps, and it also provides full support for Flutter development. This tutorial covers all the essentials to help you get up and running with Flutter in Android Studio.

Prerequisites

Before you begin, ensure that you have:

  • A computer running Windows, macOS, or Linux.
  • At least 4 GB of RAM and 2 GB of available disk space.
  • A stable internet connection for downloading the required tools.

If you don't have Android Studio installed yet, you can download it from here.

Step 1: Install Android Studio

  1. Download Android Studio:

  2. Install Android Studio:

    • Follow the installation instructions for your OS.
    • For Windows: Run the .exe installer and follow the prompts.
    • For macOS: Open the downloaded .dmg file and drag Android Studio to your Applications folder.
    • For Linux: Extract the ZIP file and run the studio.sh script from the terminal.
  3. Verify Installation:

    • Once installed, launch Android Studio to confirm that the IDE is set up properly.

Step 2: Install Flutter and Dart Plugins

After installing Android Studio, you need to install the Flutter and Dart plugins to work with Flutter projects. Here's how to do it:

  1. Start Android Studio:

    • Open Android Studio from your desktop or application menu.
  2. Open Plugin Preferences:

    • For macOS: Navigate to Preferences > Plugins.
    • For Linux and Windows: Go to File > Settings > Plugins.
  3. Search for Plugins:

    • In the Plugin settings window, search for "Flutter" using the search bar.
  4. Install Flutter Plugin:

    • Select the Flutter plugin from the search results and click Install.
  5. Install Dart Plugin:

    • After installing the Flutter plugin, Android Studio will prompt you to install the Dart plugin as well. Click Yes to install it.
  6. Restart Android Studio:

    • After the installation is complete, click Restart to apply the changes.

Step 3: Set Up the Flutter SDK

  1. Download the Flutter SDK:

    • Go to the official Flutter website: https://flutter.dev.
    • Download the stable release for your operating system.
  2. Extract and Set the Path:

    • Extract the Flutter SDK to an appropriate location on your system.
    • For Windows: Add the flutter/bin directory to your system’s PATH environment variable.
    • For macOS and Linux: Add the following line to your terminal’s configuration file (.bashrc or .zshrc):
      export PATH="$PATH:[PATH_TO_FLUTTER_DIRECTORY]/flutter/bin"
  3. Verify Installation:

    • Open a terminal window (or command prompt for Windows).
    • Run the command:
      flutter doctor
    • This command checks your environment and displays a report of the status of your Flutter installation. Ensure that there are no issues (all checkmarks should be green).

Step 4: Create a New Flutter Project

  1. Start a New Flutter Project:

    • Open Android Studio and click on Start a New Flutter Project from the welcome screen.
  2. Configure the Flutter Project:

    • Select Flutter Application as the project type and click Next.
    • Verify that the Flutter SDK path is correct (it should point to the location where you extracted the Flutter SDK).
    • Enter your Project Name (e.g., myapp) and specify the project location.
    • Choose a description for the project and click Next.
  3. Project Configuration:

    • Set the Package Name. This will be used as the identifier for your app.
    • Enter your Company Domain in reverse format (e.g., com.example).
    • Click Finish and Android Studio will set up the Flutter project for you.

Step 5: Understand the Flutter Project Structure

Once the project is created, Android Studio will generate a directory structure for your Flutter app:

  • lib: Contains the main Flutter code (main.dart).
  • android: Android-specific code and configuration files.
  • ios: iOS-specific code and configuration files.
  • test: Contains test files for unit testing the application.

Key File:

  • main.dart: This file contains the entry point for the Flutter app. By default, it displays a simple app with a Material Design interface.

Step 6: Run the Application

To run your app and see it in action:

  1. Configure an Android Emulator or Physical Device:

    • Open the AVD Manager by navigating to Tools > AVD Manager in Android Studio.
    • Create a new virtual device or use a connected physical Android device.
  2. Select the Target Device:

    • Once the emulator is set up, select the device in the target selector at the top of Android Studio.
  3. Run the App:

    • Click the Run button (green play icon) in the toolbar, or press Shift + F10.
    • Android Studio will build the app and launch it on the selected device.
  4. View the App:

    • After the app is built and installed, you should see the starter app running on your device. The default app displays a floating action button that, when clicked, increments a counter.

Troubleshooting Tips

  • If the app doesn't run, make sure your Android emulator or device is set up correctly.
  • Ensure that your Flutter and Dart SDKs are correctly configured by running flutter doctor in the terminal.
  • If you encounter any issues with Android Studio or plugins, try restarting Android Studio or updating the plugins.