Je suis sur Windows et mis à jour pour Android Studio (AS) 3.0 RC1. Lorsque j'essaie de construire notre projet avec gradle via AS ou un terminal, il s'arrête, le Stacktrace est à la fin. La partie étrange est que, sur mes collègues Mac, cela ne fait que commencer.
Donc, je suppose que quelque chose ne va pas avec le chemin. Je n'ai rien trouvé de spécifique à propos de cette exception BuildException. Tout le monde a une idée pourquoi le chemin semble dupliqué? C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug\C:\Development\Workspace\Project\app\build\outputs\apk\Test\debug
Que puis-je essayer de résoudre ce problème? J'ai nettoyé, reconstruit et redémarré tout ce que je pouvais.
Mise à jour Je viens de mettre à jour AS en 3.0 RC 2 et j'obtiens toujours le même problème.
Mise à jour Même chose avec la version stable AS 3.0 :(
>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)
Avec la version stable d'Android Studio 3.0, j'ai creusé un peu plus profondément. Il s'avère que notre script pour nommer l'APK n'a pas fonctionné, mais ne fonctionnait que sous Windows.
Ancien script:
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)
}
}
}
Script fixe:
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
Dans votre fichier Gradle (au niveau du module), utilisez-vous applicationVariants pour renommer votre apk ou des choses du genre?.
Android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
Ce code corrigera le problème. !! Il y a un changement mineur à la réponse ci-dessus dans ce script
Je suis en train de créer la même application avec Android Studio 3.0 sous Linux ou Windows . Après la mise à niveau vers Gradle 3.0.1, je rencontrais un problème similaire sous Windows alors qu'il fonctionnait correctement sous Linux:
Erreur: L'exécution a échoué pour la tâche ': smsreminder: packageDebug' . > Impossible de créer le répertoire C:\Utilisateurs\Florent\AndroidStudioProjects\MonApp\myapp\build\sorties\apk\debug\C:\Utilisateurs\Florent\AndroidStudioProjects\MonApp\monapp\build\sorties\apk\debug
Et grâce à la réponse ci-dessus de Leo, j'ai rendu ce nom plus sympathique apk:
outputFileName = "${variant.name}-${variant.versionName}.apk"
=> produces: debug-x.y.apk
outputFileName = output.outputFile.name + ".${variant.versionName}.apk"
=> produces: MyAppName.x.y.apk
Sinon, je trouvais que cela fonctionnait aussi si on voulait conserver les valeurs par défaut:
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"))