当前位置:网站首页>After flutter was upgraded from 2.2.3 to 2.5, the compilation of mixed projects became slower

After flutter was upgraded from 2.2.3 to 2.5, the compilation of mixed projects became slower

2022-06-25 16:00:00 Favorite grapes

As the title ,Flutter from 2.2.3 Upgrade to 2.5 After the version ,build The time is very long , It is found that all the dependency information in the project is printed in the built console , Lead to longer time .

Solution 1

look for flutter SDK Storage location of , modify flutter.gradle file :

File path :$flutter_sdk$/packages/flutter_tools/gradle/flutter.gradle

apply plugin: FlutterPlugin

class FlutterPlugin implements Plugin<Project> {
    
    
    ......
    
    @Override
    void apply(Project project) {
    
        this.project = project

        def rootProject = project.rootProject
          //  Just adjust this paragraph of notes 
// rootProject.tasks.register('generateLockfiles') {
    
// rootProject.subprojects.each { subproject ->
// def gradlew = (OperatingSystem.current().isWindows()) ?
// "${rootProject.projectDir}/gradlew.bat" : "${rootProject.projectDir}/gradlew"
// rootProject.exec {
    
// workingDir rootProject.projectDir
// executable gradlew
// args ":${subproject.name}:dependencies", "--write-locks"
// }
// }
// }

        ......
        }

Solution 2

 take gradle Version upgrade to and flutter The version used is consistent , here 2.5.1 Corresponding gradle Version is ,6.7.0

The analysis process

1、build A lot is printed in the window dependence Information

build In the process of ,build The window will print out the operation of each step , In the view window , I found that a lot of dependence Information , I remember in gradle There is such an instruction in the instruction of , You can print all dependence Information about , At that time, it was to check whether there were repeated dependencies . The print here may be some build Mission , This information was printed .

2、 Analyze recent code changes

Restore the code to a branch state , See if it's because of the recent gradle Problems caused by modification , After switching the branch, no change occurs , The above information is still printed .

3、 Only recently flutter upgrade

Later, I thought that recently, only right flutter Upgraded , therefore , take flutter Degraded , After demotion, I found build The process no longer prints dependent information , Upgrade it back ,build The process presents dependent information .

4、 lookup flutter Module building process

Since it is flutter Module problem , Then check its build file , So in the module gradle The following line is found in

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Then find the corresponding file , It is found that all dependent codes are added to the code . So I adjusted the notes to , You can cancel printing all dependent information . The framework process returns to normal , No longer takes too long .

原网站

版权声明
本文为[Favorite grapes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190538056998.html