Android приложение

1 месяц назад

Начните создавать приложения Flutter для Android в Windows

Важно: выполняйте это руководство последовательно. Пропуск шагов может привести к ошибкам.

Системные требования

Чтобы установить и запустить Flutter, ваша среда Windows должна соответствовать следующим требованиям:

Требования к оборудованию

Ваша среда разработки Windows Flutter должна соответствовать следующим минимальным требованиям к оборудованию.

 

Requirement Minimum Recommended
x86_64 CPU Cores 4 8
Memory in GB 8 16
Display resolution in pixels WXGA (1366 x 768) FHD (1920 x 1080)
Free disk space in GB 10.0 10.0

Требования к программному обеспечению

Чтобы написать и скомпилировать код Flutter для мобильных устройств, у вас должна быть следующая версия Windows и перечисленные пакеты программного обеспечения.

Операционная система

Flutter поддерживает 64-битную версию Microsoft Windows 10 или более позднюю версию. Эти версии Windows должны включать необходимую Windows PowerShell 5.0 или более позднюю версию.

Инструменты разработки

Загрузите и установите версии для Windows следующих пакетов:

Git для Windows 2.27 или более поздней версии для управления исходным кодом.
Android Studio 2023.1 (Hedgehog) для отладки и компиляции кода Java или Kotlin для Android. Flutter требует полной версии Android Studio.
Разработчики предыдущего программного обеспечения обеспечивают поддержку этих продуктов. Для устранения проблем с установкой обратитесь к документации соответствующего продукта.

Когда вы запускаете текущую версию  flutter doctor, она может отображать другую версию одного из этих пакетов. Если да, установите рекомендуемую версию.

Настройте текстовый редактор или IDE.

Вы можете создавать приложения с помощью Flutter, используя любой текстовый редактор или интегрированную среду разработки (IDE) в сочетании с инструментами командной строки Flutter.

Использование IDE с расширением или плагином Flutter обеспечивает завершение кода, подсветку синтаксиса, помощь в редактировании виджетов, отладку и другие функции.

Популярные варианты включают в себя:

Команда Flutter рекомендует установить Visual Studio Code 1.77 или более позднюю версию, а также расширение Flutter для VS Code. Эта комбинация упрощает установку Flutter SDK.

Установка Flutter SDK

Для установки Flutter SDK вы можете использовать расширение VS Code Flutter или загрузить и установить пакет Flutter самостоятельно.

Используйте VS Code для установки

Чтобы установить Flutter с помощью этих инструкций, убедитесь, что у вас установлен Visual Studio Code 1.77 или более поздней версии, а также расширение Flutter для VS Code.

Подсказка VS Code для установки Flutter

  1. Запустите VS Code.

  2. Чтобы открыть палитру команд, нажмите Control + Shift + P.

  3. В палитре команд введите flutter.

  4. Выберите Flutter: Новый проект.

  5. VS Code предложит вам найти SDK Flutter на вашем компьютере.

    1. Если у вас установлен SDK Flutter, нажмите «Найти SDK».

    2. Если у вас не установлен Flutter SDK, нажмите Download SDK.

    3. При выборе этого варианта вам откроется страница установки Flutter, если вы не установили Git для Windows, как указано в предварительных требованиях к средствам разработки.

  6. На вопрос «Какой шаблон Flutter?» игнорируйте его. Нажмите Esc. Вы можете создать тестовый проект после проверки настроек разработки.

Загрузите Flutter SDK

  1. Когда откроется диалоговое окно «Выбор папки для Flutter SDK», выберите, куда вы хотите установить Flutter.

    Для начала VS Code помещает вас в ваш профиль пользователя. Выберите другое место.

    Учитывать %USERPROFILE% или C:\dev.

    Предупреждение:

    Не устанавливайте Flutter в каталог или путь, который соответствует одному или обоим из следующих условий:

    • Путь содержит специальные символы или пробелы.
    • Путь требует повышенных привилегий.

    Например, C:\Program Files не соответствует обоим условиям.

  2. Click Clone Flutter.

    While downloading Flutter, VS Code displays this pop-up notification:

    content_copy
    Downloading the Flutter SDK. This may take a few minutes.
    

    This download takes a few minutes. If you suspect that the download has hung, click Cancel then start the installation again.

  3. Once it finishes downloading Flutter, the Output panel displays.

    content_copy
    Checking Dart SDK version...
    Downloading Dart SDK from the Flutter engine ...
    Expanding downloaded archive...
    

    When successful, VS Code displays this pop-up notification:

    content_copy
    Initializing the Flutter SDK. This may take a few minutes.
    

    While initializing, the Output panel displays the following:

    content_copy
    Building flutter tool...
    Running pub upgrade...
    Resolving dependencies...
    Got dependencies.
    Downloading Material fonts...
    Downloading Gradle Wrapper...
    Downloading package sky_engine...
    Downloading flutter_patched_sdk tools...
    Downloading flutter_patched_sdk_product tools...
    Downloading windows-x64 tools...
    Downloading windows-x64/font-subset tools...
    

    This process also runs flutter doctor -v. At this point in the procedure, ignore this output. Flutter Doctor might show errors that don’t apply to this quick start.

    When the Flutter install succeeds, VS Code displays this pop-up notification:

    content_copy
    Do you want to add the Flutter SDK to PATH so it's accessible
    in external terminals?
    
  4. Click Add SDK to PATH.

    When successful, a notification displays:

    content_copy
    The Flutter SDK was added to your PATH
    
  5. VS Code may display a Google Analytics notice.

    If you agree, click OK.

  6. To enable flutter in all PowerShell windows:

    1. Close, then reopen all PowerShell windows.
    2. Restart VS Code.

If you have installed all prerequisites and the Flutter SDK, you should be able to start developing Flutter on Windows for .

Configure Android development

Configure the Android toolchain in Android Studio

helpHelp

  1. Start Android Studio.

    The Welcome to Android Studio dialog displays.

  2. Follow the Android Studio Setup Wizard.

  3. Install the following components:

    • Android SDK Platform, API 34.0.0
    • Android SDK Command-line Tools
    • Android SDK Build-Tools
    • Android SDK Platform-Tools
    • Android Emulator

Configure your target Android device

Set up the Android emulator

helpHelp

To configure your Flutter app to run in the Android emulator, follow these steps:

  1. Enable VM acceleration on your development computer.

  2. Start Android Studio.

  3. Go to the Settings dialog to view the SDK Manager.

    1. If you have a project open, go to Tools > Device Manager.

    2. If the Welcome to Android Studio dialog displays, click the More Options icon that follows the Open button and click Device Manager from the dropdown menu.

  4. Click Virtual.

  5. Click Create Device.

    The Virtual Device Configuration dialog displays.

  6. Select either Phone or Tablet under Category.

  7. Select a device definition. You can browse or search for the device.

  8. Click Next.

  9. Click x86 Images.

  10. Click one system image for the Android version you want to emulate.

    1. If the desired image has a Download icon to the right of the Release Name, click it.

      The SDK Quickfix Installation dialog displays with a completion meter.

    2. When the download completes, click Finish.

  11. Click Next.

    The Virtual Device Configuration displays its Verify Configuration step.

  12. To rename the Android Virtual Device (AVD), change the value in the AVD Name box.

  13. Click Show Advanced Settings.

  14. Scroll to Emulated Performance.

  15. From the Graphics dropdown menu, select Hardware - GLES 2.0.

    This enables hardware acceleration.

  16. Verify your AVD configuration. If it is correct, click Finish.

    To learn more about AVDs, check out Managing AVDs.

  17. In the Device Manager dialog, click the Run icon to the right of your desired AVD. The emulator starts up and displays the default canvas for your selected OS version and device.

Agree to Android licenses

helpHelp

Before you can use Flutter and after you install all prerequisites, agree to the licenses of the Android SDK platform.

  1. Open an elevated console window.

  2. Run the following command to enable signing licenses.

    content_copy
    $ flutter doctor --android-licenses
    

    If you accepted the Android Studio licenses at another time, this command returns:

    content_copy
    [========================================] 100% Computing updates...
    All SDK package licenses accepted.
    

    You can skip the next step.

  3. Before agreeing to the terms of each license, read each with care.

Troubleshooting licensing issues

How to fix the error of finding Java install

Check your development setup

helpHelp

Run Flutter doctor

The flutter doctor command validates that all components of a complete Flutter development environment for Windows.

  1. Open PowerShell.

  2. To verify your installation of all the components, run the following command.

    content_copy
    C:\> flutter doctor
    

As you chose to develop for mobile, you do not need all components. If you followed this guide, the result of your command should resemble:

content_copy

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.0, on Windows A.B chipset, locale en)
[✓] Windows version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Chrome - develop for the web
[!] Visual Studio - develop Windows apps
[✓] Android Studio (version 2023.1 (Hedgehog) or later)
[✓] VS Code (version 1.86)
[✓] Connected device (1 available)
[✓] Network resources

! Doctor found issues in 2 categories.

Troubleshoot Flutter doctor issues

When the flutter doctor command returns an error, it could be for Flutter, VS Code, Android Studio, the connected device, or network resources.

If the flutter doctor command returns an error for any of these components, run it again with the verbose flag.

content_copy

C:\> flutter doctor -v

Check the output for other software you might need to install or further tasks to perform.

If you change the configuration of your Flutter SDK or its related components, run flutter doctor again to verify the installation.

Manage your Flutter SDK

To learn more about managing your Flutter SDK install, check out the following resources.

Все еще не везет? Мы можем помочь тебе

Создайте заявку и мы свяжемся с вами в ближайшее время.

Открыть тикет