Gradle项目同步失败

时间:2014-03-23 15:54:51

标签: android android-studio

我在Windows 8上新安装了Android studio 0.4.6。

在创建新项目或导入新项目时,我收到“Gradle项目同步失败”。 我尝试了以下无济于事。

  1. 使缓存无效/重新启动。
  2. 从用户主目录中删除.gradle并自动下载。
  3. 删除所有.iml和.idea文件夹。
  4. 降级为jdk 1.7。
  5. 减少堆大小。
  6. 完全卸载并删除了AS的所有文件并重新安装。
  7. 将gradle-wrapper.properties更新为1.10。将本地路径设置为gradle,并将build.gradle更新为0.9 +。
  8. 仍为同一错误“Gradle Project同步失败” 有没有人知道我可以尝试的任何其他事情?

    编辑:

    我从build.gradle中删除了额外的括号,这些是我得到的新错误。

    14.503 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
            01:18:14.514 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.j
            ava:69)       
            01:18:14.522 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    
            01:18:14.529 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExe
            cuter.java:35)
            01:18:14.539 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
            01:18:14.546 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
            01:18:14.554 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecu
            ter.java:42)  
            01:18:14.564 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.ja
            va:52)        
            01:18:14.571 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
            01:18:14.578 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.ja
            va:43)        
            01:18:14.586 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
            01:18:14.594 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecuto
            r.java:79)    
            01:18:14.601 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecuto
            r.java:63)    
            01:18:14.608 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:5
            1)            
            01:18:14.617 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33)
            01:18:14.625 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.Factories$1.create(Factories.java:22)
            01:18:14.634 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:198)
            01:18:14.641 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:266)
            01:18:14.655 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore
            .java:135)    
            01:18:14.662 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(Default
            TaskArtifactStateCacheAccess.java:95)
            01:18:14.669 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31)
            01:18:14.675 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
            01:18:14.684 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
            01:18:14.693 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
            01:18:14.699 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
            01:18:14.706 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
            01:18:14.713 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
            01:18:14.723 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
            01:18:14.731 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
            01:18:14.737 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
            01:18:14.746 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
            01:18:14.753 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
            01:18:14.760 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.
            java:64)      
            01:18:14.767 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
            01:18:14.774 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
            01:18:14.783 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
            01:18:14.792 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
            01:18:14.799 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
            01:18:14.806 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
            01:18:14.813 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201
            )             
            01:18:14.823 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174
            )             
            01:18:14.832 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
            01:18:14.839 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
            01:18:14.846 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
            01:18:14.854 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
            01:18:14.862 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.Main.doAction(Main.java:46)
            01:18:14.868 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
            01:18:14.875 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.Main.main(Main.java:37)
            01:18:14.885 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
            01:18:14.893 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
            01:18:14.899 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
            01:18:14.906 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
            01:18:14.913 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
            01:18:14.923 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
            01:18:14.930 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.internal.LoggedErrorException: Failed to run c
            ommand:       
                    C:\Users\shreZ~\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\aapt.exe package -v -f --no-crunch -I C:\Users\shreZ~\AppData\Local\Android\android-st
            udio\sdk\platforms\android-19\android.jar -M C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\manifests\debug\AndroidManifest.xml -S C:\Users\shreZ~\AndroidStudioP
            rojects\MyApplication2\app\build\res\all\debug -A C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\assets\debug -m -J C:\Users\shreZ~\AndroidStudioProjects\MyAppli
            cation2\app\build\source\r\debug -F C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.example.myapplication2.ap
            p --output-text-symbols C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\symbols\debug
            Error Code:
                    -1073741816
    
            01:18:14.939 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:39)
            01:18:14.948 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:66)
            01:18:14.957 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(An
            notationProcessingTaskFactory.java:236)
            01:18:14.964 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(Annotat
            ionProcessingTaskFactory.java:212)
            01:18:14.971 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(Anno
            tationProcessingTaskFactory.java:223)
            01:18:14.978 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(Annotat
            ionProcessingTaskFactory.java:201)
            01:18:14.986 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
            01:18:14.993 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
            01:18:15.000 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.ja
            va:80)        
            01:18:15.007 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.j
            ava:61)       
            01:18:15.014 [ERROR] [org.gradle.BuildExceptionReporter]        ... 52 more
            01:18:15.025 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: com.android.ide.common.internal.LoggedErrorException: Failed to run command:
                    C:\Users\shreZ~\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\aapt.exe package -v -f --no-crunch -I C:\Users\shreZ~\AppData\Local\Android\android-st
            udio\sdk\platforms\android-19\android.jar -M C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\manifests\debug\AndroidManifest.xml -S C:\Users\shreZ~\AndroidStudioP
            rojects\MyApplication2\app\build\res\all\debug -A C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\assets\debug -m -J C:\Users\shreZ~\AndroidStudioProjects\MyAppli
            cation2\app\build\source\r\debug -F C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.example.myapplication2.ap
            p --output-text-symbols C:\Users\shreZ~\AndroidStudioProjects\MyApplication2\app\build\symbols\debug
            Error Code:
                    -1073741816
    
            01:18:15.033 [ERROR] [org.gradle.BuildExceptionReporter]        at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandLineRunner.java:98)
            01:18:15.041 [ERROR] [org.gradle.BuildExceptionReporter]        at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandLineRunner.java:69)
            01:18:15.048 [ERROR] [org.gradle.BuildExceptionReporter]        at com.android.builder.AndroidBuilder.processResources(AndroidBuilder.java:736)
            01:18:15.058 [ERROR] [org.gradle.BuildExceptionReporter]        at com.android.builder.AndroidBuilder$processResources.call(Unknown Source)
            01:18:15.066 [ERROR] [org.gradle.BuildExceptionReporter]        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.groovy:95)
            01:18:15.074 [ERROR] [org.gradle.BuildExceptionReporter]        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.groovy:64)
            01:18:15.081 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
            01:18:15.091 [ERROR] [org.gradle.BuildExceptionReporter]        ... 60 more
            01:18:15.100 [ERROR] [org.gradle.BuildExceptionReporter]
            01:18:15.109 [LIFECYCLE] [org.gradle.BuildResultLogger]
            01:18:15.117 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
            01:18:15.127 [LIFECYCLE] [org.gradle.BuildResultLogger]
            01:18:15.138 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 32.027 secs
    

2 个答案:

答案 0 :(得分:0)

根据错误消息, build.gradle 文件中存在语法错误:第6行的额外结束括号。删除该大括号,重新同步项目,如果有您仍然无法解决的错误,请在您的问题中发布完整的 build.gradle 文件。

答案 1 :(得分:0)

转到文件 - >设置 - >构建,执行,部署 - >点击Gradle - >使用本地gradle分布 - >选择Gradle文件夹的确切位置 - >单击“应用”,然后单击确定。

之后,如果gradle sync仍然失败。在build.gradle(Module:app)文件中做一点改动(例如,在任何地方放置一个空格并将其删除)。 Studio将要求同步您的gradle文件,点击"立即同步"在屏幕的右上角。

这将正确同步您的gradle。