Flutter From Now On (1): Environment configuration

Environment configuration based on vscode

First add relevant extensions
Join the expansion
and then use vs to create a new flutter project
. Way:

  • ctrl+shift+p brings up the command panel Command Palette
  • Or call it in 【View】

Enter the command:
Flutter:New Project
create new project
But at this time, it will prompt that the flutter sdk is not installed, so we go to install the sdk and
download it here: https://flutter.dev/docs/development/tools/sdk/releases#windows
Unzip after downloading (recommended to download the latest dev version)
Put the bin folder path into the system variable
insert image description here
and then verify it in the cmd window:
first, we enter it
flutter
to check whether it is successful
, and then verify other dependencies.
flutter doctor
As a result, we found a problem again:

C:\Users\chengxsh>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, v1.10.1, on Microsoft Windows [Version 10.0.16299.1087], locale zh-CN)
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.

Android Studio comes with Android sdk, which may be used in the future. To install Android Studio directly,
download it here http://www.android-studio.org/
This is an exe file, just install it directly.

Then we continue to create a new project in the vscode command palette.

The remaining configuration problems will be recorded here when they arise.


Problems when installing Android studio

During installation, you will be prompted to choose standard or customize. It is better to choose the latter, so that you can choose some dependencies, such as the installation disk of sdk and Android emulator. These files are a bit large, and the problems I encountered when running the code after installation under standard have been resolved after installing through customize. (In fact, the company's computer system is too small =_=)
Regarding the Android sdk and AVD 1 issues, I haven't really figured it out, so let's study it if something goes wrong.
After installing Android Studio, you also need to install the relevant flutter plug-ins, and the Dart language will also be installed along with it. Basically, you don’t need to worry about other things.
The environment is finally configured.

Our purpose is to learn flutter, and then create a demo through instructions.
flutter create myapp
This project is actually a small APP that displays the number of times the button is clicked,
but some problems appeared during the debugging process.
Refer to here:
The solution to initializing gradle or resolving dependencies timeout in flutter
and some other articles, the main modified files are these two

  • flutter\packages\flutter_tools\gradle\flutter.gradle under the flutter installation path
  • android/tools/build/gradle/ under the project

The main reason is that the speed of accessing foreign marven warehouse 2 is too slow, so we changed it to Ali's source.
After modifying these, you can debug normally.

insert image description here

Can't open AVD problem

After a while, I opened Android Studio again, and found that there was no way to debug at this time.
The main reason is that this is not installed
, so close Hyper-V and restart it. Download the installable version
A hardware accelerator to speed up the running of the Android virtual machine on the x86 platform
here (windows and MacOS versions are available)

Another 180M file is installed in the AVD.
But at this time, I found that it might be a problem with the company's network. I connected to the mobile network and tried again, and it worked.


  1. Android Virtual Device is the virtual device that Android runs on, and it is recognized by the Android emulator. For an Android build to run, an AVD must be created. ↩︎

  2. Regarding gradle and marven, here are two relatively simple blogs: Understanding Gradle in Ten Minutes , Warehouse of Marven Basic Tutorial . ↩︎

Guess you like

Origin blog.csdn.net/qq_41809961/article/details/100821800