Flutter项目是能运行的,打开Flutter里面的Android项目才会报下面错误。
1 2 3 4 5 6 |
8:34 Gradle sync started 8:35 Gradle sync failed: Could not create task ':image_picker:generateDebugUnitTestConfig'. this and base files have different roots: D:\Pensoon\flutter_property_check_gd\build\image_picker and C:\Users\XXX\AppData\Roaming\Pub\Cache\hosted\pub.flutter-io.cn\image_picker-0.8.3+2\android. (52 s 230 ms) 8:35 Gradle sync started 8:35 Gradle sync failed: Could not create task ':image_picker:generateDebugUnitTestConfig'. this and base files have different roots: D:\Pensoon\flutter_property_check_gd\build\image_picker and C:\Users\XXX\AppData\Roaming\Pub\Cache\hosted\pub.flutter-io.cn\image_picker-0.8.3+2\android. (2 s 588 ms) |
1 2 3 4 5 6 7 8 9 |
$ .\gradlew clean build Configuration on demand is an incubating feature. FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':url_launcher_android:test'. > Could not create task ':url_launcher_android:testDebugUnitTest'. > this and base files have different roots: D:\Source\xxxx\build\url_launcher_android and C:\Users\Administrator\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\url_launcher_android-6.0.25\android. |
报错的项目配置信息如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
buildscript { ext.kotlin_version = '1.8.0' repositories { maven { url "https://maven.aliyun.com/nexus/content/groups/public/" } maven { url "https://maven.aliyun.com/nexus/content/repositories/google" } google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { maven { url "https://maven.aliyun.com/nexus/content/groups/public" } maven { url "https://maven.aliyun.com/nexus/content/repositories/google" } google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } |
Flutter一开始Android build是没问题的,开发着突然就报这个下面的错误,开始怀疑是不是有什么缓存啥的,然后各种排除都没找到什么原因,后面想着降版本吧,kotlin降了没用,后面尝试最后一个Gradle降版本竟然成功了。
build.gradle文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// 报错版本 classpath 'com.android.tools.build:gradle:7.0.0' // 报错版本 classpath 'com.android.tools.build:gradle:7.3.1' // 报错版本 classpath 'com.android.tools.build:gradle:7.4.2' // 解决版本 classpath 'com.android.tools.build:gradle:4.1.3' // 解决版本 classpath 'com.android.tools.build:gradle:4.2.2' |