Android Studio 0.4.2: Gradle 项目同步失败错误

在更新到0.4.2之后,我在打开一个项目时得到了这个错误: “分级项目同步失败。基本功能(如编辑、调试)无法正常工作”

事件日志显示如下:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.


at org.gradle.launcher.daemon.bootstrap.DaemonGreeter.parseDaemonOutput(DaemonGreeter.java:34)
at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(DefaultDaemonStarter.java:109)
at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startDaemon(DefaultDaemonStarter.java:90)
at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:95)
at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:72)
at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:149)
at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:100)
at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:143)
at org.gradle.tooling.internal.consumer.connection.ActionAwareConsumerConnection.run(ActionAwareConsumerConnection.java:40)
at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter$1.run(DefaultBuildActionExecuter.java:53)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
at org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
2014-01-12 02:57:48,886 [  33025]   INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at 'C:/android/workspace_studio/Noggle'
org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.9-all.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:43)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:170)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$000(GradleProjectResolver.java:61)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$1.fun(GradleProjectResolver.java:117)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$1.fun(GradleProjectResolver.java:113)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:182)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:113)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:61)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:471)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:549)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:373)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:436)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:153)
Caused by: org.gradle.api.GradleException: Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at http://gradle.org/docs/1.9/userguide/gradle_daemon.html
Please read below process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.


at org.gradle.launcher.daemon.bootstrap.DaemonGreeter.parseDaemonOutput(DaemonGreeter.java:34)
at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(DefaultDaemonStarter.java:109)
at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startDaemon(DefaultDaemonStarter.java:90)
at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:95)
at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:72)
at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:149)
at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:100)
at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:143)
at org.gradle.tooling.internal.consumer.connection.ActionAwareConsumerConnection.run(ActionAwareConsumerConnection.java:40)
at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter$1.run(DefaultBuildActionExecuter.java:53)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
at org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
2014-01-12 02:57:48,893 [  33032]   WARN - nal.AbstractExternalSystemTask - A fatal exception has occurred. Program will exit.


com.intellij.openapi.externalSystem.model.ExternalSystemException: A fatal exception has occurred. Program will exit.


at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:185)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:113)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:61)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:471)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:549)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:373)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:436)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:153)


2014-01-12 02:57:48,895 [  33034]   WARN - .project.GradleProjectImporter -
2014-01-12 02:57:48,895 [  33034]   INFO - .project.GradleProjectImporter - A fatal exception has occurred. Program will exit.




Consult IDE log for more details (Help | Show Log)
2014-01-12 02:57:48,941 [  33080]   INFO - ution.rmi.RemoteProcessSupport - Port/ID: 21325/Maven3ServerImpl5ed05101
2014-01-12 02:57:49,424 [  33563]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/remote-servers.xml file is null
2014-01-12 02:57:50,185 [  34324]   INFO - tor.impl.FileEditorManagerImpl - Project opening took 13482 ms

版本0.4.1对我来说表现得非常好。

423670 次浏览
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.

看起来相当明确: 你的操作系统找不到足够的内存来启动一个新的 Java 进程,在这个例子中就是 Gradle 构建器。可能您没有足够的 RAM,或者没有足够的交换区,或者您同时运行着太多其他内存消耗过大的进程。

这里也一样,升级到0.4.2也打破了我的情况的一切..。 它与内存使用没有任何关系: 我有8G 的内存和3.5 G 的空闲 ATM,所以没有足够的内存启动一个 JVM 是胡扯..。

实际上,它可能与 Gradle 版本有关,我查看了错误日志,发现了这个:

2014-01-1409:00:30,918[61112] Nal.AbstractExternalSystemTask-Project 使用的是 最小支持的版本是0.7。 请更新依赖项的版本 在 build.gradle 文件中使用“ com.android.tools.build: gradle”。

您正在使用的是1.8版本,这是不支持的。请使用 版本1.9 项目的 Gradle 设置或在项目的 Gradle 包装(如果 适用) Openapi.externalSystem.model. ExternalSystemException: 项目正在使用旧版本的 Android Gradle 插件 最低支持版本是0.7.0。请更新 在 build.gradle 文件中依赖“ com.android.tools.build: gradle”

-

您正在使用的是1.8版本,这是不支持的。请使用 版本1.9。

请指向该项目的 Gradle 支持的 Gradle 版本 设置或在项目的 Gradle 包装(如果适用。)

好吧,我自己修好了。 在 project 目录中,转到/gradle/wrapper 目录,并将 gradle-wrapper 属性文件编辑为:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip

在 Android Studio 中打开项目,选择/src 目录中的 build.gradle 文件并将其编辑为:

dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}

像这样修复之后,我发现了这篇文章: Http://tools.android.com/recent/androidstudio040released

我想我可以回答我自己的问题。 这招对我很管用。

  1. 文件-> 无效缓存/重新启动
  2. 关闭 Android Studio
  3. 在用户主目录中重命名/delete. gradle 文件夹
  4. 重新启动 Android Studio,让它下载所有它需要的 Gradle 材料
  5. 逐步建立成功!
  6. 重建计划... 成功!

出于好奇,我比较了旧的和新的梯级的结构... ... 它们很不一样!

所以我想看看0.4.2是怎么运行的:)

在 Android Studio 反馈站点上报告了这个问题之后,他们为我找到了一个解决方案。我现在使用的是 Gradle 1.10和 Android Studio 0.4.3。

下面是这个网页的链接,描述了我是如何修复我的网页的: Https://code.google.com/p/android/issues/detail?id=65219

希望这个能帮上忙!

我也有同样的问题,但最终我可以永远解决它
步骤:

  1. 从项目文件夹中删除 gradle.gradle文件夹。
  2. 在 Android Studio 中: 然后打开您的项目: 文件-> 设置-> 编译器-> 级别: 启用 offline mode
    注意: 在相对较新的 Android 工作室,脱机模式已经被移动到等级设置。 enter image description here
  3. 关闭你的项目: 文件-> 关闭项目
  4. 连接到 Internet 并再次打开您的项目,然后让 Android Studio 下载它想要的东西

如果成功,那么 :)
别的

  1. 如果您再次遇到 gradle project sync failed,请按照以下步骤操作:
  2. 这个目录下载最新的 gradle 软件包
  3. 将它提取出来并放在某个地方(例如 f: gradle-1.10)
  4. 转到您的 Android Studio 并加载您的项目,然后打开 文件-> 设置-> 等级,在此页面上单击 Use local gradle distribution
  5. 在这里输入你的分级文件夹地址
    enter image description here

恭喜你完成了!

这几天我已经面对这个问题很多次了,上面的答案非常好。我正在寻找这个问题的确切原因,在我的情况下,我发现缓慢的互联网或没有互联网在您的机器上(假设您正在采取的项目,以窗口从 Mac,这可能不是必需的)。

我注意到在构建时它停止获取 URL (http://. maven.org/)。我不知道为什么安卓工作室再次做这些事情,但这似乎是唯一的问题在我的情况下。

我有这个问题,当我开始我的项目,没有足够的内存为梯度。我在一个解决方案中搜索了一个小时,其中包括上面给出的变量,但随后我关闭了浏览器并重启了 IDE。有趣的是,如果您运行浏览器或游戏后,成功启动 IDE 和项目,它仍然正常工作。希望这个解决方案对某些人有用。 附注: 对不起我的英语知识(来自学校)。

所有你要做的就是从用户中删除 .gradle,粘贴,并在 Android Studio 中验证更新,它将完美工作!

按照 Carlos 的步骤后,我最终删除了

用户 MyPath.AndroidStudioPreview 目录

然后重新导入的项目,它似乎完全解决了我的问题的同时,并加速我的 Android 工作室

希望对大家有帮助

我在网上找到了一个答案,它对我很有效,因此它是:

当你得到 grade 项目同步失败错误,错误详情:

初始化 VM 时发生错误,无法保留足够数量 对象堆空间错误: 无法创建 Java 虚拟 错误: 发生了一个致命的异常。程序将退出。

然后,在 Windows 上,请访问:

控制面板 > 系统 > 高级(标签) > 环境变量 > 系统变量 > 新增:

变量名称 _JAVA_OPTIONS和变量值 -Xmx512M

保存它,重新启动 AS。这次它可能会工作,就像它对我做的那样。

资料来源: http://www.savinoordine.com/android-studio-gradle-windows-7/

我有 Android Studio 0.8.9,在论坛上工作了几个小时之后,我最终成功地手动下载了 Gradle (最新版本) ,然后转到: C: 用户。Gradle 包装器删除了 gradle-1.12-all,并用最近下载的归档文件替换了本地归档文件,还替换了提取的数据; 在重新启动 Android Studio 之后... ... 他做了一些下载、构建和各种各样的工作,但最终还是成功了。.祝你们好运!

我总是移除。渐变文件夹从% USERS% 文件夹,并重新启动工作室。当启动 IDE 时,它再次下载具有所有依赖项的 gradle。 它的工作完美。

  1. 打开文件-> 设置
  2. 选择格拉德尔
  3. 标记“使用本地分销”,并选择大家庭的路径 对于 ex: C:/Users/high _ hope/. gradle/wrapper/dists/gradle-2.1-all/27drb4udbjf4k88eh2ffdc0n55/gradle-2.1 然后选择服务目录路径 C:/Users/high _ hope/. gradle
  4. 应用所有更改
  5. 打开文件-> 使缓存/重新启动无效..。
  6. 选择“重新启动”

对于那些正在升级到 Android Studio 1.0版本的用户来说,如果你使用的是0.14.0或更高版本的 Gradle 插件,你应该在 build.Gradle 文件中把“ runProGuard”替换为“ minifyEnable”。也就是说。

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

这就是我在 Android Studio 1.0中的成功之处。2:

文件-> 设置-> 级别设置‘使用默认级别包装’

其他方法似乎对我不起作用。

今天我遇到了同样的错误,但是,我使用的是 Android Studio 1.0.2。我没有解决的问题是,我开始了一个项目,最低的 SDK 4.4(API 19) ,所以当我检查的版本,我注意到,在文件-> 项目结构-> 应用程序,我发现 Android 5作为一个编译 SDK 版本。我把它改回4.4了。

我看到了这个错误: ”错误: 编译 android-21需要使用 JDK7进行编译

对我来说,解决方案是 给你,我必须在其中更新项目结构中的 JDK 位置。

我也有同样的错误。我从 android sdk 管理器中删除了 android 存储库并重新安装了它。

我没有使用 Android Studio,但是遇到了同样的问题。我必须更新最新的 JAVA jdk 并将 JAVA _ HOME 设置为该 jdk。

加载项目: > 构建,执行,部署: > (检查)编译器独立模块并行。