更新到0.4.2后,打开项目时出现此错误: 'Gradle项目同步失败。基本功能(例如编辑,调试)将无法正常工作'
事件日志显示:
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对我来说表现非常好。
答案 0 :(得分:280)
我假设我可以回答我自己的问题.... 这对我有用。
出于好奇,我比较了旧的.gradle和新的结构...它们非常不同!
所以我会看到0.4.2如何:)
答案 1 :(得分:72)
我有同样的问题,但最后我可以永远解决它 步骤:
gradle
和.gradle
个文件夹。 offline mode
如果成功,则:)
其他
gradle project sync failed
,请按以下步骤操作:Use local gradle distribution
祝贺你完成了!
答案 2 :(得分:16)
同样,更新到0.4.2也打破了我的一切...... 它与内存使用无关:我有8 gig的内存,我有3.5 gig free atm,所以没有足够的内存来启动JVM就是公牛......
实际上它可能与Gradle版本有关,我查看错误日志并找到了:
2014-01-14 09:00:30,918 [61112]警告 - nal.AbstractExternalSystemTask - Project正在使用旧版本 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中打开项目并在/ src目录中选择build.gradle文件并将其编辑为:
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
像这样修复后我发现了这篇文章: http://tools.android.com/recent/androidstudio040released 强>
答案 3 :(得分:8)
答案 4 :(得分:5)
在Android Studio反馈网站上报告问题后,他们为我找到了解决方案。我现在正在使用Gradle 1.10和Android Studio 0.4.3。
以下是该页面的链接,其中描述了我如何修复我的: https://code.google.com/p/android/issues/detail?id=65219
希望这有帮助!
答案 5 :(得分:4)
我在网上找到了一个答案,它对我有用,因此在这里:
当您获得gradle项目同步失败错误时,错误详细信息:
VM初始化期间发生错误无法保留足够的内容 对象堆空间错误:无法创建Java虚拟 机。错误:发生了致命异常。程序将退出。
然后,在Windows上,请转到:
控制面板>系统>高级(标签)>环境变量>系统变量>新:
变量名_JAVA_OPTIONS
和变量值-Xmx512M
保存,重启AS。这次可能会有效,就像它对我一样。
来源:http://www.savinoordine.com/android-studio-gradle-windows-7/
答案 6 :(得分:3)
我从最近几天开始多次面对这个问题,上面的答案完全正常。我一直在寻找这个问题的确切原因,在我的情况下,我发现您的机器上网速度较慢或没有互联网(假设您正在将项目带到Mac上的窗口,可能不需要)。
我注意到在构建时它停止了获取URL(http:// .maven.org / )。我不知道为什么android studio再次做这些事情,但这似乎是我案件中唯一的问题。
答案 7 :(得分:3)
对于那些升级到Android Studio v1.0的用户,看到错误Gradle DSL方法未找到:'runProguard',如果您使用的是gradle插件的0.14.0或更高版本,则应替换“runProguard”在build.gradle文件中使用“minifyEnabled”。即。
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
答案 8 :(得分:2)
我有Android Studio 0.8.9,在论坛上玩了几个小时后,最终对我有用的事情是手动下载Gradle(最新版本)然后转到:C:\ Users \ .gradle \ wrapper \ dists \ gradle-1.12 -all \\并用最近下载的存档替换本地存档,并替换提取的数据;重新启动Android Studio后......他做了一些下载和构建以及各种各样的东西,但它终于奏效了......祝你好运!
答案 9 :(得分:2)
我没有使用Android Studio,但遇到了同样的问题。我不得不更新最新的java jdk并将JAVA_HOME设置为jdk。
答案 10 :(得分:2)
这适用于Android Studio 1.0.2:
档案 - >设置 - > Gradle Set'使用默认的Gradle包装。'
其他方法似乎对我没用。
答案 11 :(得分:2)
按照Carlos的步骤后,我最终删除了
C:\ Users \ MyPath.AndroidStudioPreview目录
然后重新导入项目,它似乎完全解决了我的问题,同时加速我的AndroidStudio
希望它可以帮助任何人
答案 12 :(得分:1)
我有同样的错误。我从android sdk manager中删除了android存储库并重新安装了它。它奏效了。
答案 13 :(得分:1)
加载项目:>构建,执行,部署:>(检查)编译器中的独立模块。
答案 14 :(得分:0)
我总是从%USERS%文件夹中删除.gradle文件夹并再次启动工作室。启动IDE时,它会再次使用所有依赖项下载gradle。 它的工作完美。
答案 15 :(得分:0)
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
看起来相当明确:您的操作系统找不到足够的RAM来启动新的Java进程,在本例中是Gradle构建器。也许你没有足够的RAM,或者没有足够的交换,或者你有太多其他需要大量内存的进程同时运行。
答案 16 :(得分:0)
您需要做的就是从用户中删除.gradle
,粘贴并验证Android Studio中的更新,它将完美运行!
答案 17 :(得分:0)
今天我遇到了同样的错误,但是,我使用的是Android Studio 1.0.2。我做了什么解决问题是我开始了一个项目,最低SDK 4.4(API 19),所以当我检查版本时,我注意到在File-> ProjectStructure-> app我发现Android 5作为编译SDK版本。我把它改回4.4。
答案 18 :(得分:0)
我看到这个错误以及: “错误:compileSdkVersion android-21需要使用JDK 7进行编译”
对我来说,找到了解决方案here,我必须更新项目结构中的JDK位置。
答案 19 :(得分:0)
当我开始我的项目并且没有足够的RAM用于gradle时,我遇到了这个问题。我搜索了一个小时的解决方案,包括上面给出的变体,但后来我关闭了我的浏览器并重新启动了我的IDE。有趣的是,如果您在成功启动IDE和项目后运行浏览器或游戏,它仍然可以正常工作。希望这个解决方案对某些人有用。 附:对不起我的英语知识(来自学校)。