在将flutter升级到3版本后,我存在的项目无法构建

8 人关注

我正在使用flutter 2.10.0版本进行项目工作,它工作得很好,但在将flutter升级到3.0.0版本后,我的项目无法构建,它给了我这个错误

[        ] > Task :app:compileFlutterBuildDebug FAILED
[        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[        ] Use '--warning-mode all' to show the individual deprecation warnings.
[        ] See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
[        ] 1 actionable task: 1 executed
[        ] FAILURE: Build failed with an exception.
[        ] * Where:
[        ] Script '/home/user/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1156
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildDebug'.
[        ] > Process 'command '/home/user/snap/flutter/common/flutter/bin/flutter'' finished with non-zero exit value 1
[        ] * Try:
[        ] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[        ] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 18s
[ +550 ms] Exception: Gradle task assembleDebug failed with exit code 1
    
android
flutter
gradle
GNassro
GNassro
发布于 2022-05-12
3 个回答
Dazly Gonsalves
Dazly Gonsalves
发布于 2022-05-14
已采纳
0 人赞同

This blog post might help you out:

如果你用Flutter工具创建一个新的项目,你可能会注意到,现在生成的文件使用最新版本的Gradle和 Android Gradle插件。对于现有项目,您需要手动 将Gradle的版本提升到7.4,将Android Gradle的版本提升到7.1.2。

5个小时后,我终于撞见了正确的答案。谢谢你的分享,我投了+1票!
Md. Kamrul Amin
Md. Kamrul Amin
发布于 2022-05-14
0 人赞同

我修复了它,更新了'build.gradle'从。

classpath("com.android.tools.build:gradle:3.5.3")
classpath("com.android.tools.build:gradle:3.5.4")

See more info in:

https://developer.android.com/studio/releases/gradle-plugin#4-0-0

如果上述方法不能解决这个错误,请尝试这样做。

在改变了以下一行之后。 distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip

android/gradle/wrapper/gradle-wrapper.properties

只需要改变版本号。

Ran the following command: cd android && ./gradlew clean

GNassro
GNassro
发布于 2022-05-14
0 人赞同

I tried the solution of Kamrul Hasan Jony 但它总是无法建立。

因此,对我有效的解决方案是。