Gradle 项目同步失败,没有消息,在命令行上工作
Gradle project sync failed without Messages, worked on command-line
在 Android Studio 中,同步失败:
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
命令行 gradle installDebug
有效。 "Messages" 视图中没有消息。在idea.log
中,出现了以下NullPointerException
:
2018-02-04 14:53:15,233 [ thread 15] WARN - ea.IdeaSyncPopulateProjectTask - Sync failed: null
java.lang.RuntimeException: java.lang.NullPointerException
at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:188)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:680)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:685)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:469)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:458)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.dispose(ProjectDataManager.java:401)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:156)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:198)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:204)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doSelectiveImport(IdeaSyncPopulateProjectTask.java:206)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:156)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access[=11=]0(IdeaSyncPopulateProjectTask.java:51)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.run(IdeaSyncPopulateProjectTask.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:726)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess(CoreProgressManager.java:176)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:137)
at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:334)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.intellij.openapi.extensions.Extensions.disposeArea(Extensions.java:168)
at com.intellij.openapi.module.impl.ModuleImpl.dispose(ModuleImpl.java:153)
at com.intellij.openapi.util.Disposer.execute(Disposer.java:48)
at com.intellij.openapi.util.Disposer.execute(Disposer.java:44)
at com.intellij.openapi.util.objectTree.ObjectTree.executeActionWithRecursiveGuard(ObjectTree.java:151)
at com.intellij.openapi.util.objectTree.ObjectTree.executeUnregistered(ObjectTree.java:163)
at com.intellij.openapi.util.objectTree.ObjectTree.executeAll(ObjectTree.java:132)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:123)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:119)
at com.intellij.openapi.module.impl.ModuleManagerImpl$ModuleModelImpl.dispose(ModuleManagerImpl.java:836)
at com.intellij.openapi.externalSystem.service.project.AbstractIdeModifiableModelsProvider.dispose(AbstractIdeModifiableModelsProvider.java:421)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.execute(ProjectDataManager.java:404)
at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$null(ExternalSystemApiUtil.java:458)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1023)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$executeProjectChangeAction(ExternalSystemApiUtil.java:458)
at com.intellij.openapi.application.TransactionGuardImpl.run(TransactionGuardImpl.java:303)
at com.intellij.openapi.application.impl.LaterInvocator.run(LaterInvocator.java:165)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:410)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access0(EventQueue.java:98)
at java.awt.EventQueue.run(EventQueue.java:715)
at java.awt.EventQueue.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:827)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:655)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2018-02-04 14:53:15,234 [ thread 15] INFO - e.project.sync.GradleSyncState - Gradle sync failed (4s 121ms)
Using Invalidate Caches/Restart
and removing the .gradle
folder 没有帮助。为什么是这样?它是如何固定的?
在设置 > 构建、执行、部署 > Gradle 中取消设置本地 gradle 分发后(为调试此问题而设置),Android Studio 提出更新到 gradle:3.0.1
来自 gradle:3.0.0
。这修复了它。
之前采取的步骤:
- 将
google()
存储库添加到 buildscript
和 allprojects
- 将
compileSdkVersion
和 targetSdkVersion
升级到 27
- 将所有
com.android.support
库升级到 26.1.0
将 Android Studio 升级到 3.1.3 后,我遇到了类似的错误。我不记得我之前使用的确切版本 -- 第 2 版系列。
我收到这些错误的原因是因为我使用的 Gradle 插件版本太低。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
...
}
一旦我将版本从 2.2.3
更新到 2.3.3
,Android Studio 就能够继续并给我更有意义的错误消息,例如
Gradle sync failed: Minimum supported Gradle version is 3.3. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in gradle/wrapper/gradle-wrapper.properties to gradle-3.3-all.zip
从那里开始,只需解决版本兼容性问题即可。
对我来说,这是一个简单的解决方案:我从我的项目中删除了一个模块,但忘记从 settings.gradle
中删除它
也许这可以帮助某人
在 Android Studio 中,同步失败:
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.
命令行 gradle installDebug
有效。 "Messages" 视图中没有消息。在idea.log
中,出现了以下NullPointerException
:
2018-02-04 14:53:15,233 [ thread 15] WARN - ea.IdeaSyncPopulateProjectTask - Sync failed: null
java.lang.RuntimeException: java.lang.NullPointerException
at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:188)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:680)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:685)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:469)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:458)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.dispose(ProjectDataManager.java:401)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:156)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:198)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:204)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doSelectiveImport(IdeaSyncPopulateProjectTask.java:206)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:156)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access[=11=]0(IdeaSyncPopulateProjectTask.java:51)
at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.run(IdeaSyncPopulateProjectTask.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:726)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess(CoreProgressManager.java:176)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:137)
at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:334)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at com.intellij.openapi.extensions.Extensions.disposeArea(Extensions.java:168)
at com.intellij.openapi.module.impl.ModuleImpl.dispose(ModuleImpl.java:153)
at com.intellij.openapi.util.Disposer.execute(Disposer.java:48)
at com.intellij.openapi.util.Disposer.execute(Disposer.java:44)
at com.intellij.openapi.util.objectTree.ObjectTree.executeActionWithRecursiveGuard(ObjectTree.java:151)
at com.intellij.openapi.util.objectTree.ObjectTree.executeUnregistered(ObjectTree.java:163)
at com.intellij.openapi.util.objectTree.ObjectTree.executeAll(ObjectTree.java:132)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:123)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:119)
at com.intellij.openapi.module.impl.ModuleManagerImpl$ModuleModelImpl.dispose(ModuleManagerImpl.java:836)
at com.intellij.openapi.externalSystem.service.project.AbstractIdeModifiableModelsProvider.dispose(AbstractIdeModifiableModelsProvider.java:421)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.execute(ProjectDataManager.java:404)
at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$null(ExternalSystemApiUtil.java:458)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1023)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.lambda$executeProjectChangeAction(ExternalSystemApiUtil.java:458)
at com.intellij.openapi.application.TransactionGuardImpl.run(TransactionGuardImpl.java:303)
at com.intellij.openapi.application.impl.LaterInvocator.run(LaterInvocator.java:165)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:410)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access0(EventQueue.java:98)
at java.awt.EventQueue.run(EventQueue.java:715)
at java.awt.EventQueue.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:827)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:655)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2018-02-04 14:53:15,234 [ thread 15] INFO - e.project.sync.GradleSyncState - Gradle sync failed (4s 121ms)
Using Invalidate Caches/Restart
and removing the .gradle
folder 没有帮助。为什么是这样?它是如何固定的?
在设置 > 构建、执行、部署 > Gradle 中取消设置本地 gradle 分发后(为调试此问题而设置),Android Studio 提出更新到 gradle:3.0.1
来自 gradle:3.0.0
。这修复了它。
之前采取的步骤:
- 将
google()
存储库添加到buildscript
和allprojects
- 将
compileSdkVersion
和targetSdkVersion
升级到 27 - 将所有
com.android.support
库升级到26.1.0
将 Android Studio 升级到 3.1.3 后,我遇到了类似的错误。我不记得我之前使用的确切版本 -- 第 2 版系列。
我收到这些错误的原因是因为我使用的 Gradle 插件版本太低。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
...
}
一旦我将版本从 2.2.3
更新到 2.3.3
,Android Studio 就能够继续并给我更有意义的错误消息,例如
Gradle sync failed: Minimum supported Gradle version is 3.3. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in gradle/wrapper/gradle-wrapper.properties to gradle-3.3-all.zip
从那里开始,只需解决版本兼容性问题即可。
对我来说,这是一个简单的解决方案:我从我的项目中删除了一个模块,但忘记从 settings.gradle
也许这可以帮助某人