This article has participated in the Denver Nuggets Creators Camp 3 “More Productive writing” track, see details: Digg project | creators Camp 3 ongoing, “write” personal impact.
Say in advance
- This article is just a tutorial on building the Android development environment for Flutter on Windows
- This article has three cores: code editor & Flutter SDK (including Dart SDK) & Android SDK
The body of the
1. Add environment variables (domestic mirror)
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Copy the code
Note: Run the preceding two commands in Linux, and add them manually in Windows
2. Configure Git environment
Download: git-scm.com/download/wi…
Note: Flutter requires Git support. You can download and install Flutter directly
3. Configure the Java environment
This step is not currently required, if necessary go to this link to download the JDK package (usually 8.0 will do)
Download address: www.oracle.com/java/techno…
“At a later stage, when you package apK, you need to create a keystore for app signing that requires a JDK environment.”
Download the Flutter SDK
Flutter. Dev /docs/get-st…
Note: Do not place the file in a high permission path, such as C:\Program Files\, and make sure that the path is in full English.
Find flutter_console.bat in the flutter file and double-click to run and start the flutter command line. Then you can run the flutter command on the flutter command line.
Such as:
flutter doctor
Copy the code
5. Configure environment variables
If you want to run the flutter command on Windows, you need to add the following environment variables to user PATH:
export PATH = D:\flutter\bin
Copy the code
Note: D:\flutter\bin is my installation directory. You must follow your flutter SDK directory.
6. Install Android Studio
The purpose of installing It is not to force you to write code with it, but to get the latest version of the Android SDK that comes with Android Studio!
Download it at www.androiddevtools.cn/
7. Check the environment
Run from the command line:
flutter doctor
Copy the code
The following command output indicates that the configuration is complete:
However, this article has only completed the first 3 of the 4 items shown in the diagram (FLutter SDK, Android SDK, Android Studio). The fourth item is the Android virtual machine, which will be created and started when we run the application.
Note: it appears in the picture! Warning does not affect the running of the program. If an X appears, the environment is wrong and corrective action is required.
For example, if you don’t have an Android certificate after installing Android Studio, you’ll need to run:
flutter doctor --android-licenses
Copy the code
You just need to do the right thing until running the FLUTTER doctor command doesn’t show the X sign!
8. Install the plug-in
Start Android Studio, go to Plugins (File > Settings > Plugins) to search for Flutter and install the Flutter plugin
9. Create projects
Start Android Studio > File > New Flutter Project
10. Install the VM
Click tool -avD Manager on the top menu of Android Studio, select Create Virtual Device, select THE VM type, select Android OS version (usually 9.0 or higher), and start the VM
11. Run the project
If it fails, the reasons are most likely as follows:
Edit the build.gradle file in the Android directory of the project and remove the Google () and jcenter() lines. Change to Ali’s link. As shown in figure:
buildscript { repositories { // google() // jcenter() 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'} } dependencies {classpath 'com. Android. View the build: gradle: 3.1.2'}} allprojects {repositories {/ / Google () / / jcenter() 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' } } }Copy the code
Modify the Flutter. Gradle file in the Flutter SDK package (……) Flutter packages flutter_tools gradle flutter. Gradle
repositories {
//google()
//jcenter()
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' }
}
Copy the code
12. Use VS Code instead
To change your code editor to VS Code, just configure vs Code plug-ins called Flutter and Dart and start the vm you just created.
To start a VM, perform the following operations:
Create a new.bat file and say:
Exe path -netdelay None -netspeed full -avd Specifies the name of the PREVIOUSLY created VMCopy the code
Mine is as follows:
C:\Users\pc\AppData\Local\Android\Sdk\emulator\emulator.exe -netdelay none -netspeed full -avd Nexus_6P_API_29
Copy the code
Then double-click to start the virtual machine without having to start Android Studio first.