关于新空项目

时间:2018-06-08 19:08:44

标签: java android android-studio gradle android-gradle

  1. 我的操作系统是win8.1
  2. 我已经下载了Android Studio版本: android-studio-ide-173.4720617-windows.exe并安装它。 (由于ASCII问题,我不得不做mklink /D "c:\Android-Sdk" "C:\Users\мет\AppData\Local\Android\sdk"
  3. 我已启动Android Studio并已选择Start new Android Studio project
  4. Application name,其他所有内容都默认保留。
  5. 已检查Phone and Tablet
  6. 选择了Empty activity
  7. Activity name,其他所有内容都默认保留。
  8. 点击了Finish按钮,然后出现了构建错误:
  9.   

    org.gradle.api.tasks.TaskExecutionException:任务执行失败   ':应用程序:mergeDebugResources&#39 ;.在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)     在   org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)     在   org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)     在   org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)     在   org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)     在   org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)     在   org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)     在   org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)     在   org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)     在   org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)     在   org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)     在   org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)     在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:248)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)     在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)     在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access 200 $(DefaultTaskPlanExecutor.java:79)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98)     在   org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)     在   org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)     在   org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)     在   org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46)     在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:624)     在   org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)     在java.lang.Thread.run(Thread.java:748)引起:   com.android.build.gradle.tasks.ResourceException:错误:   java.util.concurrent.ExecutionException:   com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:   检查日志以获取详细信息   com.android.build.gradle.tasks.MergeResources.doFullTask​​Action(MergeResources.java:296)     在   com.android.build.gradle.internal.tasks.IncrementalTask​​.taskAction(IncrementalTask​​.java:106)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)at   org.gradle.api.internal.project.taskfactory.IncrementalTask​​Action.doExecute(IncrementalTask​​Action.java:46)     在   org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)     在   org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:121)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)     ... 32更多引起:错误:   java.util.concurrent.ExecutionException:   com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:   检查日志以获取详细信息   com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:332)     在   com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:301)     在   com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:412)     在   com.android.build.gradle.tasks.MergeResources.doFullTask​​Action(MergeResources.java:285)     ... 48更多抑制:java.lang.RuntimeException:某些文件   处理失败,请参阅日志以获取详细信息   com.android.builder.internal.aapt.QueuedResourceProcessor.waitForAll(QueuedResourceProcessor.java:121)         在   com.android.builder.internal.aapt.QueuedResourceProcessor.end(QueuedResourceProcessor.java:141)         在   com.android.builder.internal.aapt.v2.QueueableAapt2.close(QueueableAapt2.java:104)         在   com.android.build.gradle.tasks.MergeResources.doFullTask​​Action(MergeResources.java:293)         ... 48更多引起:java.util.concurrent.ExecutionException:   java.util.concurrent.ExecutionException:   com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:   检查日志以获取详细信息   com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)     在   com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)     在   com.google.common.util.concurrent.AbstractFuture $ TrustedFuture.get(AbstractFuture.java:79)     在   com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:327)     ... 51更多引起:java.util.concurrent.ExecutionException:   com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:   检查日志以获取详细信息   com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)     在   com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)     在   com.google.common.util.concurrent.AbstractFuture $ TrustedFuture.get(AbstractFuture.java:79)     在   com.android.builder.internal.aapt.v2.QueueableAapt2.lambda $编译$ 0(QueueableAapt2.java:136)     在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:624)     ... 1更多引起:   com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2错误:   检查日志以获取详细信息   com.android.builder.png.AaptProcess $ NotifierProcessOutput.handleOutput(AaptProcess.java:443)     在   com.android.builder.png.AaptProcess $ NotifierProcessOutput.err(AaptProcess.java:395)     在   com.android.builder.png.AaptProcess $ ProcessOutputFacade.err(AaptProcess.java:312)     在   com.android.utils.GrabProcessOutput $ 1.run(GrabProcessOutput.java:104)

    任何人都可以提供帮助。提前谢谢。

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题。如果有其他人遇到这种问题,我会说明我发现的内容以及我如何解决这个问题。

  1. 首先,我试图找出真正的错误。为此,我从gradlew.bat packageDebug开始cmd作为administrator。您也可以Terminal中的Android Studio执行此操作。我得到的错误是Android Studio无法在c:\users\?\.gradle\....文件夹中找到某些文件。由于我在安装过程中遇到过ASCII问题,因此我知道我的用户文件夹名称包含非ASCII字符是个问题。
  2. 要解决此问题,我需要更改用户文件夹名称。我这样做就像article.中所描述的那样 更改用户文件夹名称后,一切正常,我的错误消失了。我无法相信Android Studio无法使用Unicode并且无法使用ASCII。这是非常失望的。

    我希望这会对某人有所帮助。