Get the Flutter SDK


Reference:Flutter Chinese Community

(https://flutter.cn/docs/get-started/install/windows)

  • Decompress the package and place the entire Flutter directory in your desired flutter SDK installation directory (for example, D:\flutter; Do not place this directory in a directory that requires additional permissions, such as C:\Program Files\).
  • Find the flutter_console.bat file in the flutter directory and double-click to execute the batch script

Update environment variables

1. In the user variables column, check whether there is an entry for Path:

  • If there is one, simply add the full path to the flutter\bin directory to the folder. To an existing value as a separator.
  • If not, create a new Path variable in the user environment variable and take the full Path of flutter\bin as the value of the new variable.




2. Configure the mirror configuration for Flutter

  • Reference: use Flutter under the network environment in China (https://flutter.cn/community/china), it is strongly recommended that preferred configuration this step
  • In the user variables column, create a new user environment variable:
    • PUB_HOSTED_URL -> https://pub.flutter-io.cn
    • FLUTTER_STORAGE_BASE_URL -> https://storage.flutter-io.cn




Download and install Android Studio

To prepare

    • Create a new folder, such as D:\ Android, and create androidSDK and androidStudio as the corresponding directories



Download address:Android Studio

(https://developer.android.google.cn/studio/)

Installation Reference:Android Studio installation details

(https://www.jianshu.com/p/de318c8a0fc6)

    • Pay attention to:Set the installation path of the software and SDK to the path prepared in the first step.
    • Please check all the options on the left of this step


Install the Flutter and Dart plug-ins

The installation process is as follows:

  1. Open Android Studio.

  2. Open plug-in Settings (On Windows, open File > Settings > Plugins).

  3. Select Marketplace, then select the Flutter plugin and click Install.

  4. When prompted to install the Dart plug-in, click Yes.

  5. When prompted to Restart, click Restart.

Five, check the installation environment

1. The androidSDK path

2. DartSDK path



3. FlutterSDK path

4. Check whether the previously configured user environment variables take effect

5. Run flutter Doctor

  1. Open a new console window and enter Flutter Doctor execution. If it says there are any platform-dependent dependencies, then you need to follow the instructions. Such as:If the error persists after installing the AS and checking the configuration, it may be that the FLUTTER configuration is incorrect. Solution:
  • Start flutter_console.bat in the Flutter directory and run the following command
  • Flutter config –android-sdk=” /path/to/android/ SDK”
  • Flutter config –android-studio-dir=” /path/to/android/studio”
  • If the following tips, basically no problem
  • 6. Create an application

    1. New Flutter Project

    2. Select the Flutter application as the project type and click Next

    3. Enter the project name (e.g. ‘myapp’) to verify that the path shown in the Flutter SDK path field is the correct SDK path. The flutterSDK was downloaded earlier

    4. Click Finish.

    7. Run the project

    Preparation: Ensure Virtualization Technology (VTx) and Virtualization Technology for Directed I/O (VTd) are enabled. If not, perform the following steps to prevent virtual or real mobile devices from connecting

    • Press F10 repeatedly while booting to enter BIOS, select Advanced, then Select System Options, and press Enter
    • Then select Virtualization Technology (VTx) and Virtualization Technology for Directed I/O (VTd), click Save, and exit

    You can select a virtual device or use USB to connect to a real device. USB debugging must be enabled on the mobile phone




    Pit pit pit pit pit pit pit!!



    1. Click to start debugging, prompt:

    No connected devices found; please connect a device, or see flutter.io/setup

    Solution:

    • Ensure that the installation environment is correct


    • Ensure that VTx and VTd are enabled in BIOS

    • Be sure to open Android Studio as an administrator
    • If it is connected to a real computer, make sure that USB debugging and USB installation are enabled


    2. The flutter doctor detects an error



    Solution:

    Start flutter_console.bat in the Flutter directory and run the following command

    Flutter config –android-sdk=” /path/to/android/ SDK”

    Flutter config –android-studio-dir=” /path/to/android/studio”




    Error “Enable VT-x in your Bios Security Settings”

    • Press F10 repeatedly while booting to enter BIOS, select Advanced, then Select System Options, and press Enter
    • Then select Virtualization Technology (VTx) and Virtualization Technology for Directed I/O (VTd), click Save, and exit



    4. Resovle gets stuck on the first run… For a long time, and then an error will be reported.

    Finished with error: ProcessException: Process “E:\code\flutter_app” exited abnormally: Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip Unzipping

    Cause of the problem: Flutter requires a ladder to download dependencies in jCenter and Google libraries. Because Google is inaccessible to the wall, flutter stays downloaded there but cannot be downloaded.


    Method 1: Refer to 2. Configure the mirror configuration for Flutter

    Method 2:

    maven{ url ‘https://maven.aliyun.com/repository/google’ }

    maven{ url ‘https://maven.aliyun.com/repository/jcenter’ }

    maven{url ‘http://maven.aliyun.com/nexus/content/groups/public’}

    • You need to add an ali cloud image to two places of build.gradle in your app
    • You need to add the same image to your Flutter SDK’s folder flutter. Gradle. Here is the image I added after the Flutter sdk. gradle path was opened





    5. Installing build\app\outputs\apk\app. Apk… Cannot hot update code



    Solution:

    • Ensure that the installation environment is correct


    • Make sure you have administrator rights and open Android Studio as an administrator
    • If it is connected to a real computer, make sure that USB debugging and USB installation are enabled