解决Flutter运行android提示Deprecated imperative apply of Flutter‘s Gradle plugins
文章目录
- 出现场景
- 解决方案
-
- 编辑android/settings.gradle
- 编辑android/build.gradle
-
- 重新定义库变量
- 编辑android/app/build.gradle
-
- 删除fluttetRoot和plugin字段
- 添加plugins块
- 修改dependencies
出现场景
ado@adodeMacBook-Air app_demo % flutter run --profile
Launching lib/main.dart on SM G977U in profile mode...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-applyYou are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-applyRunning Gradle task 'assembleProfile'... 17.7s
运行在安卓时,出现以上的警告.
解决方案
这是因为从Flutter
3.16开始,Android gradle插件使用plugin dsl语法 plugins{}
块,
以下是移植方法