通过./gradlew运行构建时,检查构建是否因以下堆栈跟踪而失败。我已经更新了gradle到4.1和AS到3.0的帖子,面对这个问题。
出了什么问题: 任务执行失败':app:packageDefaultGlobalIndiaOnlyDebug'。
无法创建目录C:\ Users \<> \<> \<> \ app \ build \ outputs \ apk \ defaultGlobalIndiaOnly \ debug \ C:\ Users \<> \< > \<> \应用\构建\输出\ APK \ defaultGlobalIndiaOnly \调试\ C:\用户\<> \<> \<> \应用\构建\输出\ APK \ defaultGlobalIndiaOnly \调试
尝试:使用--info or --debug
选项运行以获得更多日志输出。
例外情况是:
org.gradle.api.tasks.TaskExecutionException:任务':app:packageDefaultGlobalIndiaOnlyDebug'执行失败。 at 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.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63) 在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88) 在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:197) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) 在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:80) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:105) 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:99) 在org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99) at org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 引起:org.gradle.tooling.BuildException:无法创建目录C:\ Users \<> \<> \<> \ app \ build \ outputs \ apk \ defaultGlobalIndiaOnly \ debug \ C:\ Users \<> \<> \<> \应用\构建\输出\ AP ķ\ defaultGlobalIndiaOnly \调试\ C:\用户\<> \<> \<> \应用\构建\输出\ APK \ defaultGlobalIndiaOnly \调试 在com.android.build.gradle.internal.scope.OutputScope.lambda $ parallelForEachOutput $ 10(OutputScope.java:241) 在com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236) 在com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197) 在com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181) 在com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:471) 在com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109) 在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore $ IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173) 在org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore $ StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134) 在org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore $ StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:122) 在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:197) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) ......还有27个 引起:java.lang.RuntimeException:无法创建目录C:\ Users \<> \<> \<> \ app \ build \ outputs \ apk \ defaultGlobalIndiaOnly \ debug \ C:\ Users \&lt ;> \<> \<> \应用\构建\输出\ APK \ defau ltGlobalIndiaOnly \调试\ C:\用户\<> \<> \<> \应用\构建\输出\ APK \ defaultGlobalIndiaOnly \调试 在com.android.utils.FileUtils.mkdirs(FileUtils.java:215) 在com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:664) 在com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:522) 在com.android.build.gradle.internal.scope.OutputScope.lambda $ parallelForEachOutput $ 6(OutputScope.java:186) 在com.android.build.gradle.internal.scope.OutputScope.lambda $ parallelForEachOutput $ 7(OutputScope.java:203) 在com.android.build.gradle.internal.scope.OutputScope.lambda $ null $ 8(OutputScope.java:225) 在com.android.ide.common.internal.WaitableExecutor.waitForAllTasks(WaitableExecutor.java:215) 在com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:235) ......还有42个
答案 0 :(得分:0)
找到这个@ https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
在构建时修改变体输出可能不起作用
使用Variant API来操作变量输出会被新插件破坏。它仍然适用于简单的任务,例如在构建时更改APK名称,如下所示:
library(purrr)
get_sublist <- function(group_name) {
keep(l, function(x) x[[1]][[1]] == group_name)
}
get_sublist("b")
但是,涉及访问outputFile对象的更复杂的任务不再起作用。这是因为在配置阶段不再创建特定于变体的任务。这导致插件不能预先知道所有输出,但也意味着更快的配置时间。