更新后Gradle同步失败

时间:2019-10-04 05:15:30

标签: android gradle

Android Studio要求我将gradle升级到3.5.1版,但是一旦执行,它就不再同步了,尽管我没有报告任何明显的错误...

出现的唯一错误消息是“ Gradle项目同步失败。基本功能(例如,编辑,调试)将无法正常工作。”

22:32 Gradle同步失败:org / jetbrains /插件/ gradle / util / GradleConstants 有关更多详细信息,请查阅IDE日志(“帮助” |“显示日志”)(18 s 224毫秒)

已经尝试清理项目,重建和使/重启无效,但是没有任何作用

有人可以帮我吗?


我的构建脚本:

buildscript {
    ext.kotlin_version = '1.3.50'
    ext.anko_version='0.10.8'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

还有一些我的“ idea.log”最后条目

2019-10-03 22:32:41,266 [e-1483-b03]   INFO - rationStore.ComponentStoreImpl - Saving Project 'C:\Users\mathe\Pictures\Design\ANDROID\ResistCalc' ResistCalcProjectCodeStyleConfiguration took 40 ms 
2019-10-03 22:32:41,266 [Alarm Pool]   INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 163 ms 
2019-10-03 22:32:46,056 [e-1483-b03]   WARN - un.AndroidRunConfigurationBase - Can't get application ID: Android module missing 
2019-10-03 22:32:46,056 [e-1483-b03]   WARN - un.AndroidRunConfigurationBase - Can't get application ID: Android module missing 
2019-10-03 22:32:46,056 [e-1483-b03]   WARN - un.AndroidRunConfigurationBase - Can't get application ID: Android module missing 
2019-10-03 22:32:46,056 [e-1483-b03]   WARN - un.AndroidRunConfigurationBase - Can't get application ID: Android module missing 

5 个答案:

答案 0 :(得分:2)

尝试文件->使缓存无效/重新启动

enter image description here

答案 1 :(得分:2)

在我的情况下,这是由Flutter插件引起的。只需禁用Flutter插件,同步即可再次正常工作。 这是来自日志的错误:

2019-10-04 11:33:32,903 [thread 284]   WARN - nal.AbstractExternalSystemTask - org/jetbrains/plugins/gradle/util/GradleConstants 
java.lang.NoClassDefFoundError: org/jetbrains/plugins/gradle/util/GradleConstants
    at io.flutter.utils.FlutterExternalSystemTaskNotificationListener.onSuccess(FlutterExternalSystemTaskNotificationListener.java:17)
    at com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl.onSuccess(ExternalSystemProgressNotificationManagerImpl.java:113)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:118)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:165)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:151)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.executeImpl(ExternalSystemUtil.java:563)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.lambda$execute$0(ExternalSystemUtil.java:399)
    at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:146)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:399)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$5.run(ExternalSystemUtil.java:668)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:731)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:586)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:86)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:403)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:312)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

答案 2 :(得分:0)

当未为项目设置“生成工具版本”时,会发生此问题。您只需要设置构建工具的版本

打开项目结构File->Project Structure,然后从“模块”部分的应用程序属性标签中选择“构建工具版本”。

这会将构建工具版本添加到gradle文件(Module:app)中,并重新同步项目。

答案 3 :(得分:0)

您应该尝试此操作

https://stackoverflow.com/a/58214439/11404883

它也可以帮助您:D

答案 4 :(得分:0)

最后找到了解决方案!!!!

我正在处理两个项目,一个在Kotlin,一个在Flutter。 首先,与插件存在一些冲突,因此为了不必每次交换项目时都禁用/启用它们,我选择安装两个单独的android studio安装,每个项目一个。

然后,在出现一些明显的错误之后,this answerthis video结合起来挽救了我的生活。

希望,它也可以帮助其他人。