Comprehensive summary of senior Android research and development: those pits encountered by Flutter

Author: Lu Zhao Wei

To become a good Android development, a knowledge system is essential -

Flutter is a new cross-platform development tool. The bloggers have also played for a while, step by step stepping on the pits and touching the stones to cross the river. This has suffered all kinds of pits, all kinds of Google, stackoverflow, Flutter official website I waited to check the information, but some problems could not be solved in time, so I tried to find some solutions slowly. Here I will systematically organize and share with you, I only hope that if you think the content is good, you can give me a thumbs up. By the way, comment and forward a wave

一、Unable to find git in your PATH

The error is as shown:

【the reason】

Git environment variables are not configured or configured incorrectly. The correct one should be the git root path\bin.

2. git clone downloads the Flutter source code warehouse, error: RPC failed; curl 18 transfer closed with outstanding read data remaining

【the reason】

Due to the Http protocol error, when Clone, because the default value of curl's postBuffer is too small, and the project itself may be relatively large, the download fails.

【solution:】

Open the git command line and enter git config –global http.postBuffer 524288000, and then you can enter git config –list to see if the settings just take effect.

Explanation:  The meaning of the git config -global http.postBuffer 524288000 command: it is equivalent to changing the value of curl's postBuffer to a larger value. The unit of 524288000 is B, which is equivalent to 500MB.

3. When the flutter command is executed, the 360 ​​antivirus software pop-up window prompts that there is a virus.

【solution:】

Click "Trust this file" in the lower right corner. It is recommended to temporarily close the antivirus software when executing the flutter project, as shown in the figure.

4. When the flutter install command is executed to install the apk to the simulator, an error is reported. The error message is:

【the reason】

Because of the use of native libraries. The native libraries do not support the current cpu architecture. I currently use the x86 emulator.

【solution】

Open the project root directory /android/app/build.gradle and add the following content in the android node:

splits{
    abi {
        enable true
        reset()
        include 'x86', 'armeabi-v7a','x86_64'
        universalApk true
    }
}

For details, please see the figure below:

If the above operations still do not work, change to an arm simulator or real machine to run. The following figure is a demonstration operation running on the arm simulator:

5. Problems that occur during the execution of the flutter upgrade command.

【solution】

Restart the command line and re-execute the flutter upgrade command. It will automatically download all the tools needed by the SDK. This shows that the environment is no problem, the configuration is no problem, and the network is also OK. As shown below:

Sixth, the version compatibility problem that appears in the process of compiling the project, as shown in the figure.

[The solution has the following ways]

As long as you see the error message containing which doesn't match any version, you can basically use the following solutions:

● 1.  Search in the pubspec.lock file and pubspec.yaml file in the root path of the project to ensure that the version number of the third-party plug-in library imported in the pubspec.lock file is consistent with the version number in the pubspec.yaml file.

● 2.  Compatibility issues caused by the mismatch between the third-party plug-in library version introduced in the project and the development environment. It is recommended to download the source code of the third-party plug-in library, put it in the project, and then modify the configuration information of the Flutter and Dart versions that depend on the plug-in library source code . Using source code is the best solution.

● 3.  In the Flutter cache directory of the C drive, specifically: C:\Users\Administrator\AppData\Roaming\Pub\Cache\hosted, which is a folder named pub.dartlang.org by default, we will look for it now Check if there is a folder called pub.flutter-io.cn. If there is, to save trouble, it is recommended to copy all the files in the pub.dartlang.org folder to the pub.flutter-io.cn folder. Up. If not, create a folder named pub.flutter-io.cn, and then perform the copy work. (Generally speaking, if the domestic mirror is configured, there will be a pub.flutter-io.cn folder)

Seven, flutter upgrade failed due to version compatibility issues.

【solution】

This is caused by the compatibility problem of the flutter_tools package. It may be the compatibility problem of the sdk version. We can perform flutter upgrade to upgrade Flutter and try again. If it doesn't work, follow the sixth clause.

8. Unsupported Android Studio version, meaning: Flutter plug-in does not support the current AS version.

【the reason】

The current AS is version 3.2. The Flutter plugin is not yet compatible with AS3.2 for the time being.

【solution】

It is OK to use AS development of version 3.0 or 3.1.

9. When executing flutter upgrade command to update Flutter, SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054 appears

【solution】

Open the git command line and enter git config –global http.postBuffer524288000, and then you can enter git config –list to see if the settings just take effect.

10. Errors that occur when using the flutter doctor command. This type of error may have many forms, and they all have a common keyword StartBitsTransferCOMException

Examples of several different errors I encountered are as follows:

[Solution]  There are two reasons:

(1) The BITS transmission service is not enabled:

Computer --> Right-click management --> Services and applications, click Services, and then as shown below:

Then select the one marked in the figure, right-click on the properties, and then change to automatic and confirm. As shown below:

(2) No domestic mirror is set:

If you use Flutter in China, then you may need to find a trusted mirror site synchronized with the official website to help your Flutter command line tool download the resources it needs from the mirror site. You need to set two environment variables for this: PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL, and then run the Flutter command line tool.

Need to add the domestic mirror to the environment variable. details as follows:

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

As shown in the figure below: If the download error still occurs, it is recommended to restart the computer and try again.

11. There are errors in the update_dart_sdk.ps1 file, and there are multiple error manifestations, as shown in the following 3 pictures.

【solution】

It is recommended to delete the Flutter root path /bin/cache folder, and then re-execute the flutter doctor command. The location of the Flutter root path /bin/cache folder is shown in the following figure:

At last

I am engaged in Android development by myself. I have been in the business for so long. I have also accumulated some treasured materials and shared them, hoping to help everyone improve their advanced level.

Share an Android learning PDF+architecture video+interview document+source notes collected by several big guys , advanced architecture technology advanced mind map, Android development interview topic materials, advanced advanced architecture materials

If you need it, you can learn PDF+architecture video+interview document+source notes for free on this Android

If you like this article, you might as well give me a thumbs-up, leave a message in the comment area or forward and support it~

Guess you like

Origin blog.csdn.net/River_ly/article/details/106684799