preface

Recently, I have been learning Flutter by myself. I opened a new pit to record my own operation and common problems, which is convenient for beginners like me to communicate and learn together.

Download the Flutter SDK

Clone the Repository directly with Flutter Github

Download the Android Studio

Android Studio official websiteIf you can’t open it, climb the ladder

Direct download is the installation package, personal advice under the compression package, choose hereDownload options Select the ZIP package to download, and then unzip to a directory you remember, pay attention to the path without Chinese

Configure the Android Studio

Find it in the unzipped directoryStudio64.exe, this is the AS main program, double-click to open.

If your computer does not have a global ladder, it may pop up the SDK cannot link to the error, ignore it, clickCancel

Welcome page, directNext

CustomthenNext Choose hereJDKCatalogue, generally there is no need to change, directNext Choose the interface style and choose it according to your personal preference. If it is Ubuntu, there will be an Ubuntu theme optionThe most important thing is to set up the SDK path, which is really big,Do not place system disks Continue toNextIt will start downloading the SDK and click when it’s finishedFinish, and the configuration is complete. Download can not take the ladder, now SDK server is also available in China.

The configuration is complete when you look at this screen.

At this point, you are ready to create new Android native projects. But we are still one step away from developing Flutter. Next, install the Flutter plugin.

Click on the gear in the lower right cornerConfigure(On other systems it may not be called that, but the location is the same), selectPlugins

To pop up the plugin store, enter Flutter and click Install FlutterI don’t have to agree to third party terms

The system then prompts Flutter to rely on DartThen switch to Installed to see the download progressClick on this when the download is completeRestart IDERestart the Android StudioAn extra entry was found after the restartCreate New Flutter ProjectThis is the entry to create a Flutter project. The first entry above is the entry to create an Android native project.

!

Can’t open the plugin store?

If you are in thePluginsThat step point opened after the store has been in circles, may be the need to take a ladder to go agentClick on the gear icon and selectHttp Proxy Settings The proxy Settings are shown in the picture. I can’t help you if I don’t know what to fill in

Fill it in and clickCheck connection, the inputhttps://www.google.comAnd then press Enter, and the blue thing that pops up is that the proxy Settings are successful. The agent works across Android Studio, including the plugin store, SDK downloads, and more.But it does not work with Gradle scriptsIf you need Gradle scripts to run proxies, you need to modify the global Gradle configuration or the project Gradle configuration.

Android Studio Experience Optimization (Windows only, optional)

Native android development will produce large amounts of data, what the SDK, gradle, download cache, compile cache, all all in the system tray and often result in hundreds of GB system disk said explosive detonation, before loading system is also very troublesome, and does not support the custom directory, so it is strongly recommended that make the following configuration system disk space. Android C:\Users\ user name. C:\Users\dubhe.gradle SDK directory

Modifying the SDK directory

Open Up Android Studio, open upSettings(The Mac seems to be barkingPerfrence)

If you don’t open the item still on the welcome page, gear from the lower right cornerconfigureinSettings

If you’ve already opened the project from the top menuFileEnter theSettings

Mac is the first item on the top menuPerfrence

Compressed SDK directory

SDK is a very big thing, usually tens of gigabytes of space, so here we will use a unique Windows technology, compression folder to reduce the space it takes up on the hard disk. The effect is shown in the picture.



Right-click folder properties → Advanced → check “compress content to save disk space”, and then confirm, and then determine folder properties. You will be asked if the properties apply only to the folder itself or to folders and internal files, so select folders and internal files.



A progress bar pops up showing the compression progress, depending on your CPU and hard disk. If the compression is interrupted (ordered to cancel, the computer shut down, etc.), back to file attributes menu – > advanced – > remove compression tick – set – > applications – the popup prompted to select the “apply only to the folder” – to high – check the compression – set – > applications – the popup prompted to select “is applied to the folder and internal documents” can continue to compress.

Create soft links for common directories

AndroidStudio does not support changing the location of.Android,.AndroidStudio4.0,. Gradle directories. Close AndroidStudio first. 2. Manually move the.Android,.AndroidStudio4.0,. Gradle guys to other locations 3. Open CMD 4. Enter the symbolic link command in the format mklink[space]/D[space]” symbolic link location “[space]” linked folder location “note that Spaces cannot be omitted. Quotes can be omitted but are not recommended. Because if there is a space in the directory it will not be able to recognize the instruction for example if I moved.android from the user folder on drive C to the root directory on drive D, the instruction would look something like this:

Mklink /D "C:\Users\ username \. Android ""D:\. Android"Copy the code

Then press Enter, prompting you to create a symbolic link for XXX. You can think of a symlink as a shortcut. Now there is a shortcut in the original directory C:\Users\ username \. Android that points to your new directory. Any access to the symlink is the same as accessing the new D:\. This way, when you reinstall the system, you only need to create symbolic links once again, so you don’t have to copy files and wait, and you don’t have to re-download data. Can also free up space on the system disk, is not beautiful ~ (~ ▽ ~)~

Setting environment Variables

Of course I remember this is a Flutter article. Now we add environment variables.

Right-click on “this computer”, “this computer”, “this product”, “My computer” → Properties

Click “Advanced System Settings” on the left

Click on theseniorTABThe environment variable



Double click on theSystem variablesIn thePath



Double-click on a blank line and type the Android SDK’splatfrom-toolsTo add the full path to the folder, double-click on a blank line to add Flutter SDKbinDirectory full path, then click OK.

If your environment variable looks like this when you edit it, it’s inThe existingA variable's valueAppended toIn English the semicolonEntering new content is equivalent to double clicking a blank line above.



Then if you don’t have a ladder or your ladder is very slow, you can choose to add mainland China exclusive Flutter warehouse environment variable. There are two pairs in total. pointnew, enter the name and value and press Enter.

The name value
PUB_HOSTED_URL https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL https://storage.flutter-io.cn



Finally all the way down can be saved to take effect

Configuration Flutter

Open CMD and typeflutter doctorPress Enter, which automatically downloads the missing content, and takes a long time to run for the first time (especially if you don’t have a ladder or environment variables configured). After running, if an error occurs, it will prompt what instruction should be run. According to the content of the error, baidu will take the right medicine for the case. (It’s not that I’m lazy, different machines report different errors… In the future, I will write what common mistakes I encounter.)

For example, if you encounter a prompt like this, what protocol is missing? If you copy the command behind run: and press enter, multiple protocol prompts will pop up



The configuration is complete when all checks are displayed. Yay! Now I can finally go to the new project.

Refer to the tutorial

Because Chinese website