Development of cross-platform mobile applications has become an industry standard today, and Flutter occupies a leading position among frameworks due to its performance and unified code base. However, before writing the first line of code, it is critical to properly prepare your development environment. Incorrect configuration Android Studio often leads to compilation errors, problems with the emulator and loss of precious time.
In this article we will analyze in detail the process of installing all the necessary components, from the SDK itself to setting up a virtual device. You'll learn how to avoid common pitfalls when setting paths and environment variables that are often stumbling blocks for beginners. Proper setup of the workspace is the foundation on which the speed of your future development is built.
Do not underestimate the importance of the initial configuration, since changing parameters after the fact may require a complete reinstallation of tools. We will look not only at the standard steps, but also at the nuances that the documentation sometimes omits. Ready to turn your system into a powerful tool for creating applications?
Installing the JDK and setting environment variables
The first step towards creating a working environment is to install the Java Development Kit (JDK). Although modern versions of Flutter can work with the bundled JDK, a separate installation is often required for stable operation of plugins and project building. OpenJDK version 11 or higher. The lack of a correctly configured Java environment is the most common cause of errors at the project initialization stage.
After downloading the installer, you must run it and follow the instructions of the installation wizard. It is critical to remember the JDK installation pathas it will be needed to configure system variables. By default on Windows this is usually C:\app Files\Java\jdk-17, and on macOS the path may look like /Library/Java/JavaVirtualMachines.
Next you need to add the path to the JDK to your operating system's environment variables. This will allow any tool on the system to call Java commands without specifying the full path. For Windows, this is done through the system properties menu, and for macOS and Linux - by editing the shell configuration file, for example .zshrc or .bash_profile.
Verifying the installation is carried out through the terminal or command line. Enter the command java -versionto make sure that the system sees the installed version. If the output contains a version number, the basic setup was successful and you can move on to the next step.
โ ๏ธ Warning: Do not install multiple different versions of the JDK at the same time without a clear understanding of which version is active. Version conflicts can result in unpredictable compilation errors in Android Studio.
Use the command echo $JAVA_HOME in the terminal to quickly check if the environment variable is set correctly before running heavy build processes.
Downloading and installing Android Studio
The main tool for Android development in the Flutter ecosystem is Android Studio. It is a full-featured IDE that provides all the necessary tools for code editing, debugging and profiling. You should download the distribution exclusively from the official website of the developers to avoid malicious modifications.
During the installation process, you will be asked to select components to download. Be sure to make sure that the items responsible for installation are checked Android SDK and Android Virtual Device. Failure to install these components at this point will require you to manually download them later, which will significantly complicate the setup process.
Once the installation is complete, launch the IDE. When you launch it for the first time, the setup wizard will ask you to select a theme and check for updates. It is recommended to immediately install all available updates, as they often contain security fixes and improvements to the emulator.
An important point is the choice of installation type: Standard or Custom. For most users, the Standard mode is optimal, as it automatically selects recommended paths and components. Custom mode should only be used by experienced developers who need to place the SDK on a specific drive.
Integration of Flutter and Dart plugins
Android Studio itself does not โunderstandโ the Dart language and the Flutter framework without installing the appropriate extensions. These plugins provide syntax highlighting, code completion, project navigation, and built-in tools for launching applications. Without them, development will turn into painful editing of text files.
To install, go to the settings menu via path File โ Settings (or Android Studio โ Preferences on macOS). In the section Plugins use the search on the marketplace and find the official plugin Flutter. When installing it, the studio will automatically prompt you to install the plugin Dart, which is a required dependent component.
After installing the plugins, you will need to restart the integrated development environment. This is a required step because the IDE core must initialize new code analysis modules. Ignoring the reboot will result in the framework's functions remaining unavailable.
In the Flutter plugin settings, you can specify the path to the Flutter SDK if it was installed in a non-standard location. Usually the system finds it automatically if the path is added to the variable PATH. However, manually setting the path through the settings interface ensures that the IDE uses exactly the version you intend.
โ๏ธ Checking the installation of plugins
Setting up the Android SDK and emulator
To run and test applications, you must have a virtual device or a connected physical smartphone. System images and emulators are managed via Device Manager Android Studio. This is the central hub for creating configurations for various devices.
When creating a new virtual device, you will have to select a hardware profile (for example, Pixel 6) and a system image (System Image). It is recommended to select images marked Google APIs or Google Play, as they contain a full set of services necessary for testing integrations with maps, notifications and other functions.
The table below provides recommendations for selecting system images for various testing purposes:
| Purpose testing | Recommended API Level | Image type | Features |
|---|---|---|---|
| Basic functionality | API 30-33 | Google APIs | Stable operation of most libraries |
| New functions Android | API 34+ | Google Play | Testing on the latest OS versions |
| Performance | Any | x86_64 | Hardware graphics acceleration |
| Compatibility | API 21-24 | Google APIs | Testing work on old ones devices |
After creating the device, launch it and make sure that it appears correctly in the list of connected devices. If the emulator takes a long time to load or runs with delays, check the virtualization settings in your computer's BIOS and allocate more RAM in the AVD configuration.
โ ๏ธ Attention: Emulators consume a significant amount of RAM. If you have less than 16 GB of RAM, do not run several virtual devices at the same time, this will cause the system to freeze.
What to do if the emulator does not start?
If the emulator gives an error at startup, try changing the graphics settings in the device configuration to Software or Hardware. Also make sure that virtualization technology is enabled in the BIOS (VT-x for Intel or AMD-V).
Flutter SDK and Doctor configuration
After installing all components, you need to make sure that Flutter correctly recognizes the environment. To do this, use the utility flutter doctorin the terminal. This command diagnoses the system and points out missing components or configuration errors.
Run the command in a terminal and carefully examine the output. The utility checks the availability of the Android SDK, license status, Internet connection and the presence of emulators. The status OK next to each item means that the environment is ready for use. If you see crosses or warnings, follow the instructions that the console displays.
One โโof the common problems is unaccepted Android SDK licenses. To accept them, you must execute the command flutter doctor --android-licenses and sequentially confirm agreement with the terms by entering y in response to terminal requests. Without this step, building the project will not be possible.
If flutter doctor Does not see Android Studio or SDK, check the installation paths. Sometimes you need to manually specify the path to the SDK using the command flutter config --android-sdk. Make sure there are no Cyrillic characters or spaces in the path, as build tools may not handle such folder names correctly.
Running flutter doctor regularly helps identify problems with the environment before you start writing code, saving hours of debugging non-existent errors in the project.
Creating the first project and launching
When all the settings are completed, you can start creating the first project. In Android Studio, select New Flutter Project in the create a new application menu. The wizard will prompt you to select the project type: Application, Module or Package. To get started, select Application.
At the next stage, specify the project name, description and save path. It is important to use Latin letters and underscores in the name, avoiding spaces and special characters. The path to the project should also be simple and not contain Cyrillic to avoid problems with the Gradle builder.
After creating the project structure, open the file lib/main.dart. This is the entry point to the application. You'll see a basic code template with a widget MaterialApp and a counter. Click the launch button (green triangle) in the top toolbar.
Select the target device from the list of available emulators or connected phones. The first build process may take several minutes as the system needs to download dependencies and compile the native code. After successful compilation, the application will launch on the selected device.
โ ๏ธ Attention: The interfaces of the tools and setup wizards can be updated by developers. If you do not find the described button or menu, use the settings search (Ctrl+Shift+A) to find the desired item.
Use the Hot Reload function (lightning icon) during development to see changes in the code instantly without completely reloading the application.
Solution common problems during setup
Even if you follow the instructions, specific errors may arise related to the configuration of a particular machine. One of the common problems is the error SDK location not found. It occurs when the file local.properties in the project does not contain the correct path to the Android SDK.
To solve this problem, open the file local.properties in the project root and add the line sdk.dir=Path_to_your_SDK. On Windows, the path will look like sdk.dir=C\:\\Users\\User\\AppData\\Local\\Android\\Sdk, pay attention to escaping backslashes.
Another common problem is Gradle build errors associated with version incompatibility. If the build crashes with a Java or Gradle version error, check the file build.gradle and make sure that the plugin versions match the version of the installed JDK. Sometimes clearing the cache using the command helps. flutter clean.
If the emulator is running slowly, make sure you are using an x86_64 system image and not an ARM one, unless you are using an Apple Silicon processor or an ARM laptop. Hardware graphics acceleration must be enabled in the virtual device settings for smooth animation of the Flutter interface.
Why does flutter doctor show warnings, but the project is being built?
Some warnings in flutter doctor are advisory in nature and do not block work. For example, the lack of Chrome for web development will not prevent you from building for Android. However, red crosses indicate critical errors that need to be resolved.
How to change the path to the Android SDK after installation?
The path can be changed in the Android Studio settings: File โ Settings โ Appearance & Behavior โ System Settings โ Android SDK. You also need to update the ANDROID_HOME environment variable in the system.
Is it possible to develop in Flutter without an emulator?
Yes, you can connect a physical Android device via USB. To do this, you need to enable developer mode and USB debugging in your phone settings. This often works faster and more stable than the emulator.
What to do if Flutter plugins are not installed?
Check your Internet connection and proxy settings in Android Studio. Also try updating the IDE itself to the latest version, as older versions may not be compatible with new plugins.