wake-up-neo.net

Gradle 3.0 BuildException kann kein Verzeichnis erstellen

Ich bin unter Windows und habe auf Android Studio (AS) 3.0 RC1 aktualisiert. Wenn ich versuche, unser Projekt mit Gradle via AS oder Terminal zu erstellen, wird der Stacktrace am Ende beendet. Das Seltsame ist, dass es auf meinem Mac-Kollegen einfach nur gebaut wird.

Ich vermute also, dass mit dem Pfad etwas nicht stimmt. Zu dieser BuildException konnte ich nichts Konkretes finden. Hat jemand eine Idee, warum der Pfad doppelt erscheint? C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug\C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug

Was kann ich sonst noch versuchen, dieses Problem zu beheben? Ich habe alles sauber gemacht, neu aufgebaut und alles neu gestartet.

Update Ich habe gerade AS auf 3.0 RC 2 aktualisiert und bekomme immer noch das gleiche Problem.

Update Dasselbe passiert mit dem stabilen AS 3.0 Release :(

>FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageTestDebug'.
> Cannot create directory C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug\C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageTestDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.Java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.Java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.Java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.Java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.Java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.Java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.Java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.Java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.Java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.Java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.Java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.Java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.Java:99)
at 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)
Caused by: org.gradle.tooling.BuildException: Cannot create directory C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug\C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug
at com.Android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.Java:241)
at com.Android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.Java:236)
at com.Android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.Java:197)
at com.Android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.Java:181)
at com.Android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.Java:471)
at com.Android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.Java:109)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.Java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.Java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.Java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.Java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.Java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.Java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:92)
... 27 more
Caused by: Java.lang.RuntimeException: Cannot create directory C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug\C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug
at com.Android.utils.FileUtils.mkdirs(FileUtils.Java:215)
at com.Android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.Java:664)
at com.Android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.Java:522)
at com.Android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.Java:186)
at com.Android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.Java:203)
at com.Android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.Java:225)
7
Leo Nawroth

Mit der stabilen Version von Android Studio 3.0 habe ich etwas tiefer gegraben. Es stellte sich heraus, dass unser Skript zur Benennung der APK nicht funktionierte, sondern nur unter Windows brach.

Alte Schrift:

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def outputFile = output.outputFile
        if (outputFile != null && outputFile.name.endsWith('.apk')) {
            def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")
            output.outputFile = new File(outputFile.parent, fileName)
        }
    }
}

Festes Skript:

applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "${variant.name}-${variant.versionName}.apk"
    }
}
32
Leo Nawroth

Verwenden Sie in Ihrer Gradle-Datei (Modulebene) applicationVariants, um Ihren apk oder ähnliches umzubenennen.

1
Florian Morel
Android.applicationVariants.all { variant ->
  variant.outputs.all {
      outputFileName = "${variant.name}-${variant.versionName}.apk"

Dieser Code wird das Problem beheben. !! In diesem Skript gibt es eine geringfügige Änderung der obigen Antwort

0
aswin yadav

. Ich baue gleiche App mit Android Studio 3.0 sowohl auf Linux oder Windows ..__ Nach dem Gradle Upgrade 3.0.1 hatte ich ein ähnliches Problem auf Windows, während es funktioniert auf Linux fein:

Fehler: Ausführung fehlgeschlagen für Task ': smsreminder: packageDebug' . > Kann Verzeichnis C:\Benutzer\Florent\AndroidStudioProjects\MyApp\myapp\bauen\Ausgaben\apk\debug\C:\Benutzer\Florent\AndroidStudioProjects\MyApp\myapp\bauen\Ausgaben\apk\debug

Und dank der obigen Antwort von Leo habe ich diesen freundlichen apk-Namen gemacht:

outputFileName = "${variant.name}-${variant.versionName}.apk"
=> produces: debug-x.y.apk

outputFileName = output.outputFile.name + ".${variant.versionName}.apk"
=> produces: MyAppName.x.y.apk

Ansonsten fand ich das auch, wenn man die Standardeinstellung beibehalten will:

if (org.gradle.internal.os.OperatingSystem.current().windows)
            outputFileName = "${variant.name}-${variant.versionName}.apk"
        else
            outputFileName = new File(output.outputFile.parent, outputFileName.replace(output.outputFile.name, defaultConfig.applicationId + ".apk"))
0
FlorentA