当前位置:网站首页>Flutter environment installation & operation

Flutter environment installation & operation

2022-06-24 06:28:00 Mokong 9081

Flutter Environmental installation && function

background

Flutter Environment configuration to run , Problem memo record . For example, meet Android sdkmanager tool not found and Running Gradle task 'assembleDebug'...

<!--more-->

Flutter install

Flutter Environment building

  • First download Flutter Installation package , Download address :https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
  • secondly , Unzip the downloaded file , Put the file in the specified directory , Be careful : It is recommended to put it in the root directory of the user , Because you need to specify bin File address , It's better that this directory doesn't change very often
  • then , Configure environment variables open terminal, If it is zsh, Input open .zshrc;( If it is bash, Then input. open .baseprofile) Add the following code at the end of the file , among pwd For the just unzipped flutter/bin File address ,export PATH="$PATH:`pwd`/flutter/bin"
 meanwhile , For domestic reasons , You can also add the following two environment variables 
```
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
```
 Here's the picture :
![wx20210716-170052.png](https://inews.gtimg.com/newsapp_ls/0/13773107215/0.png)
 Edit finish `.zshrc`( perhaps `.bashprofile`) After the document , Keep close , function 
```
source .zshrc
//  Edit if .bashprofile, Then input. source .bashprofile
```
 And then run `flutter doctor`, You can judge flutter Is it installed well .

Editor installation

  • Android Studio Download and install Android Studio after , There are also three places to install
    • SDK Manager, install SDK Platforms, Add the required Android version according to the actual common
    • AVD Manager, Add Android emulator
    • Plugins, add to Flutter and Dart plug-in unit
 Here's the picture :
![wecom20210716-170945.png](https://inews.gtimg.com/newsapp_ls/0/13773197016/0.png)
![wecom20210716-171251.png](https://inews.gtimg.com/newsapp_ls/0/13773206431/0.png)
![wecom20210716-171234.png](https://inews.gtimg.com/newsapp_ls/0/13773208728/0.png)
![wx20210716-170813.png](https://inews.gtimg.com/newsapp_ls/0/13773205380/0.png)
  • Xcode, Download and install directly , Then open it once .
  • VSCode, open VSCode Plug-in interface , Search for Flutter, Can be installed .

Verification environment

Input flutter doctor, Judge whether the environment is installed according to the prompt , There may be problems , Refer to the problem record below

Input flutter doctor --android-licenses, You will be prompted to choose y/N, All choices y that will do .

Create project

Use VSCode establish Flutter project , open VSCode( Remember to install Flutter plug-in unit ), Press at the same time CMD+Shift+P, Invoke shortcut commands , Input Flutter, choice Flutter: New Applicaiton Project, Here's the picture

Then select the project storage address , Project name , that will do

Running simulator

List supported emulators

flutter emulator

give the result as follows :

screen shot 2021-07-16 at 13.50.49.png

Open the specified simulator

flutter emulators --launch xxx

Running simulator

flutter run

Then select the simulator to run , as follows :

The problem record

  • function flutter doctor, Report errors :Android sdkmanager tool not found
 modify : open Android Studio, Click on Config->SDK Manager, Choose SDK Tools, Deselect the bottom `Hide Obsolete Packages`, Then you can see `Android SDK Tools(Obsolete)`, Check Apply, When the download is completed .
  • function flutter doctor --android-licenses, Report errors :Failed to install android-sdk: “java.lang.NoClassDefFoundError:
 modify : open Android Studio, Click on Config->SDK Manager, Choose SDK Tools, Deselect the bottom `Hide Obsolete Packages`, Can see `Android SDK Command-line Tools(latest)`, Check Apply, When the download is completed .
![[email protected]](https://inews.gtimg.com/newsapp_ls/0/13772656300/0.png)
  • The boot simulator is stuck Running Gradle task 'assembleDebug'...
 background : Good configuration flutter After the environment , Select Android emulator , Startup time , Consistency stuck in `Running Gradle task 'assembleDebug'...`
 reason :Gradle Of Maven The warehouse is abroad , Therefore, you need to use the alicloud image address .
 modify :
`andriod/build.gradle` In file repositories It is amended as follows 
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' }

as follows :

原网站

版权声明
本文为[Mokong 9081]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/07/20210716191500878c.html