安卓工程中导入flutter module报错

来源:11-3 Flutter Android混合开发实战-集成与调用【Android技术与Flutter融合】

伊187

2024-03-30

flutter版本:Flutter stable, 3.19.3
gradle版本
图片描述

在安卓工程settings.gradle中添加了以下代码
图片描述
报错信息:
Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by plugin class ‘FlutterPlugin’

You 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/go/flutter-gradle-plugin-apply

写回答

2回答

伊187

提问者

2024-04-01

我按照下图中重新配置了下安卓工程的settings.gradle和build.gradle文件。可以正常导入flutter工程,但是有警告。不知道大家有没有更好的方法

https://img1.sycdn.imooc.com/szimg/660a116b098d2a5f12160709.jpg

0
1
CrazyCodeBoy
什么警告呢
2024-04-02
共1条回复

CrazyCodeBoy

2024-04-01

检查下你配置的路径是否正确
0
1
伊187
路径没有问题! println("file exists ======" + new File( // new settingsDir.parentFile, // new 'flutter_proj/.android/include_flutter.groovy' // new ).exists()) 输出:file exists ======true
2024-04-01
共1条回复

Flutter从入门到进阶 实战携程网App 一网打尽核心技术

解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。

4788 学习 · 3270 问题

查看课程