我的颤振项目失败了,我犯了这个等级错误


FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle.
> Could not configure services using GradleScopeCompileServices.configure().
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1

这是我的建筑.gradle

buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

我尝试了很多东西,我改变了颤动和渐变的版本,到处看,但我仍然会犯这个错误。以前是有效的,现在不行了。Btw java版本设置为1.8

面临同样的问题。

解决方案:

  1. 2.2.3至2.2.2的降级颤振版本
  2. 删除~/.android文件夹
  3. 重新启动android工作室

这种错误有数百个原因,除了记住你以前做过什么之外,没有人知道。但无论如何,为了获得更好的解决方案,请遵循以下内容:

  • 转到"工具"选项卡,然后颤动清除

  • 转到"文件"选项卡,然后使缓存无效并重新启动

  • 按照本文中的步骤获得Gradle的最新更新

  • 最后转到android文件夹,然后构建gradle,然后在右上角你会看到编辑文件或类似的东西。。按下它,打开新窗口,让它自动更新到最后。。更好的是,如果你去文件到那个新窗口,然后选择项目结构,手动查看它会向你显示什么警告,只按更新

别忘了使用最新的Flutter SDK。

最新更新