1.4 Flutter Android setup

Flutter relies on a full installation of Android Studio to supply its Android platform dependencies. However, you can write your Flutter apps in a number of editors. this article discusses that. Install Android Studio Download and install Android Studio. Start Android Studio, and go through the ‘Android Studio Setup Wizard’. This installs the latest Android […]

Flutter relies on a full installation of Android Studio to supply its Android platform dependencies. However, you can write your Flutter apps in a number of editors. this article discusses that.

Install Android Studio

  1. Download and install Android Studio.
  2. Start Android Studio, and go through the ‘Android Studio Setup Wizard’. This installs the latest Android SDK, Android SDK Command-line Tools, and Android SDK Build-Tools, which are required by Flutter when developing for Android.
  3. Run flutter doctor to confirm that Flutter has located your installation of Android Studio. If Flutter cannot locate it, run flutter config --android-studio-dir <directory> to set the directory that Android Studio is installed to.

Set up android device

There are two ways to run and test your Flutter app. One is on a real Android device, and the other is using an Android emulator.

Set up your real Android device

To prepare to run and test your Flutter app on an Android device, you need an Android device running Android 4.1 (API level 16) or higher.

  1. Enable Developer options and USB debugging on your device. Detailed instructions are available in the Android documentation.
  2. Windows-only: Install the Google USB Driver.
  3. Using a USB cable, plug your phone into your computer. If prompted on your device, authorize your computer to access your device.
  4. In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device. By default, Flutter uses the version of the Android SDK where your adb tool is based. If you want Flutter to use a different installation of the Android SDK, you must set the ANDROID_SDK_ROOT environment variable to that installation directory.

Set up the Android emulator

If you prepare to run and test your Flutter app on the Android emulator, follow these steps:

  1. Enable VM acceleration on your machine.

  2. Launch Android Studio, click the AVD Manager icon, and select Create Virtual Device...

    • In older versions of Android Studio, you should instead launch Android Studio > Tools > Android > AVD Manager and select Create Virtual Device…. (The Android submenu is only present when inside an Android project.)
    • If you do not have a project open, you can choose Configure > AVD Manager and select Create Virtual Device…
  3. Choose a device definition and select Next.

  4. Select one or more system images for the Android versions you want to emulate, and select Next. An x86 or x86_64 image is recommended.

  5. Under Emulated Performance, select Hardware - GLES 2.0 to enable hardware acceleration.

  6. Verify the AVD configuration is correct, and select Finish.

    For details on the above steps, see Managing AVDs.

  7. In Android Virtual Device Manager, click Run in the toolbar. The emulator starts up and displays the default canvas for your selected OS version and device.

Agree to Android Licenses

Before you can use Flutter, you must agree to the licenses of the Android SDK platform. This step should be done after you have installed the tools listed above.

  1. Make sure that you have a version of Java 8 installed and that your JAVA_HOME environment variable is set to the JDK’s folder.

    Android Studio versions 2.2 and higher come with a JDK, so this should already be done.

  2. Open an elevated console window and run the following command to begin signing licenses.

    flutter doctor --android-licenses
  3. Review the terms of each license carefully before agreeing to them.

  4. Once you are done agreeing with licenses, run flutter doctor again to confirm that you are ready to use Flutter.

Author: Hi, I’m iBllex

I am a freelancer. Currently working on Golang, PHP, WordPress, React, Vue, TypeScript, Flutter and other technologies.

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *