android studio 0.4.2:Gradle项目同步失败的错误

更新到0.4.2后,打开一个项目时出现这个错误:“Gradle项目同步失败。 基本function(例如编辑,debugging)不能正常工作“

事件日志显示了这一点:

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版本对我来说performance非常好。

我假设我可以回答我自己的问题….这对我有效。

  1. 文件 – >caching失效/重新启动
  2. closuresAndroid Studio
  3. 重命名/删除用户主目录中的.gradle文件夹
  4. 重新启动Android Studio让它下载所有需要的Gradle东西
  5. Gradlebuild立成功!
  6. 重build项目….成功!

出于好奇,我把旧的格局和新格局的结构进行了比较…他们是非常不同的!

所以我会看看如何0.4.2 🙂

我有同样的问题,但最后我可以永远解决它
脚步:

  1. 从您的项目文件夹中删除gradle.gradle文件夹。
  2. 在Android Studio中:打开你的项目,然后: 文件 – >设置 – >编译器 – > gradle :启用offline mode
    注意:在相对较新的Android Studios中, 离线模式已被移至gradle设置。 在这里输入图像描述
  3. closures你的项目: 文件 – >closures项目
  4. 连接到互联网,再次打开您的项目,然后让Android Studio下载它想要的

如果成功的话:)
其他

  1. 如果遇到gradle project sync failed ,请按以下步骤操作:
  2. 从该目录下载最新的gradle软件包
  3. 解压缩并放在某个地方(例如f:\ gradle-1.10)
  4. 进入你的Android Studio并加载你的项目,然后打开File-> Settings-> gradle ,在这个页面中点击Use local gradle distribution
  5. 在那里input你的gradle文件夹地址
    在这里输入图像描述

祝贺你完成!

同样在这里,更新到0.4.2也打破了我的情况…这与内存使用无关:我有8个内存的演出,我有3.5演出免费atm,所以没有足够的内存启动一个JVM是bullocks …

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

2014-01-14 09:00:30,918 [61112] WARN – nal.AbstractExternalSystemTask – 项目使用旧版本的Android Gradle插件。 支持的最低版本是0.7.0。 请在您的build.gradle文件中更新依赖项“com.android.tools.build:gradle”的版本。

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

您正在使用Gradle版本1.8,不支持。 请使用版本1.9。

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

好吧,我自己修复它…在项目目录中,进入/ gradle / wrapper目录,并编辑gradle-wrapper属性文件到这个:

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

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

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

修复它之后,我发现这篇文章: http : //tools.android.com/recent/androidstudio040released

  1. 打开文件 – >设置
  2. selectGradle
  3. 选中“使用本地grandle发行版”,然后selectex:C:/Users/high_hopes/.gradle/wrapper/dists/gradle-2.1-all/27drb4udbjf4k88eh2ffdc0n55/gradle-2.1.1,然后select服务目录pathC :/Users/high_hopes/.gradle
  4. 应用所有更改
  5. 打开文件 – >无效的caching/重新启动…
  6. select刚才重新启动

在Android Studio反馈网站上报告问题后,他们为我find了一个解决scheme。 我现在使用Gradle 1.10和Android Studio 0.4.3。

以下是该页面的链接,并说明了我如何解决我的问题: https : //code.google.com/p/android/issues/detail?id = 65219

希望这可以帮助!

我在网上find了一个答案,它为我工作,因此这里是:

当你得到gradle项目同步失败的错误,错误的详细信息:

VM初始化期间发生错误无法为对象堆预留足够的空间错误:无法创buildJava虚拟机。 错误:发生致命exception。 程序将退出。

然后,在Windows上,请转到:

控制面板>系统>高级(选项卡)>环境variables>系统variables>新build:

variables名称_JAVA_OPTIONS和variables值-Xmx512M

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

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

我从前几天面对这个问题多次,上面的答案完全正常。 我正在寻找这个问题的确切原因,并在我的情况下,我发现在你的机器上网速慢或没有互联网(假设你正在从Mac项目到Windows,可能不需要)。

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

对于那些升级到Android Studio v1.0的用户,看到错误的Gradle DSL方法找不到:runProguard,如果你使用gradle插件的0.14.0或更高版本,你应该把“runProguard”replace为“minifyEnabled “在你的build.gradle文件中。 即

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

跟随卡洛斯步骤后,我结束了删除

C:\ Users \ MyPath.AndroidStudioPreview目录

然后重新导入项目,似乎完全解决了我的问题,同时加快我的AndroidStudio

希望它能帮助任何人

我有Android Studio 0.8.9和几个小时后在论坛上终于为我工作的东西是手动下载Gradle(最新版本),然后转到:C:\ Users \ .gradle \ wrapper \ dists \ gradle-1.12-all \ \并用最近下载的档案replace本地档案,并replace提取的数据; 重新启动Android Studio后…他做了一些下载和构build和各种东西,但它终于工作..祝你好运的人!

这是Android Studio 1.0.2的工作原理:

文件 – >设置 – > Gradle Set'使用默认的Gradle包装。

其他方法似乎并没有为我工作。

我没有使用Android Studio,但有同样的问题。 我不得不更新最新的java jdk,并将JAVA_HOME设置为该jdk。

我有同样的错误。 我从android sdkpipe理器中删除了android库,并重新安装它。 有效。

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

看起来相当清晰:你的操作系统找不到足够的内存来启动一个新的Java进程,在这个例子中就是Gradle构build器。 也许你没有足够的内存,或者没有足够的交换空间,或者你同时运行了太多的需要内存的进程。

当我开始我的项目时,我遇到了这个问题,而且没有足够的RAM来存储Gradle。 我search了一个小时的解决scheme,包括上面给出的变种,但是我刚刚closures了浏览器并重新启动了我的IDE。 有趣的是,如果你在成功启动IDE和项目后运行浏览器或游戏,它仍然正常工作。 希望这个解决scheme对别人有用。 对不起我的英语知识(来自学校)。

所有你需要做的是从用户中删除.gradle ,粘贴和validationAndroid Studio中的更新,它会完美的工作!

我总是从%USERS%文件夹中删除.gradle文件夹,并再次启动工作室。 启动IDE时,会再次下载所有依赖关系。 它的工作完美。

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

我看到这个错误伴随着:“错误:compileSdkVersion android-21需要与JDK 7编译”

对我来说, 这里find了解决scheme,我必须在项目结构中更新JDK位置。

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