gpt4 book ai didi

android - Gradle:文件名、目录名或卷标语法不正确

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:38:45 30 4
gpt4 key购买 nike

我已经安装并设置了最新版本的 Android Studio(0.3.6,11 月 14 日发布),但是在尝试构建我的项目(使用 Android Studio 新项目向导制作的简单的 hello world 项目)时,我得到了以下错误:

E:\Backups\etc\TestProj2>gradlew --stacktrace build
:Test2:preBuild UP-TO-DATE
:Test2:preDefaultFlavorDebugBuild UP-TO-DATE
:Test2:prepareDefaultFlavorDebugDependencies
:Test2:compileDefaultFlavorDebugAidl
:Test2:compileDefaultFlavorDebugRenderscript
:Test2:generateDefaultFlavorDebugBuildConfig
:Test2:mergeDefaultFlavorDebugAssets
:Test2:mergeDefaultFlavorDebugResources
:Test2:processDefaultFlavorDebugManifest
:Test2:processDefaultFlavorDebugResources
:Test2:generateDefaultFlavorDebugSources
:Test2:compileDefaultFlavorDebug
:Test2:dexDefaultFlavorDebug
The filename, directory name, or volume label syntax is incorrect.
:Test2:dexDefaultFlavorDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Test2:dexDefaultFlavorDebug'.
> Could not call IncrementalTask.taskAction() on task ':Test2:dexDefaultFlavorDe
bug'

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Test2:d
exDefaultFlavorDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
ute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
e(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
ter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
e(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailur
e(AbstractTask.java:283)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultT
askPlanExecutor.java:33)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(Def
aultCacheAccess.java:214)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(Def
aultCacheAccess.java:276)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunning
Operation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStat
eCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:78)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
tTaskPlanExecutor.java:31)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
ltTaskGraphExecuter.java:86)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
ExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExec
uter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecu
ter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
ecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions
.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:37)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.ja
va:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.GradleException: Could not call IncrementalTask.taskAc
tion() on task ':Test2:dexDefaultFlavorDebug'
at org.gradle.util.JavaMethod.invoke(JavaMethod.java:69)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
ctTask.java:527)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
ctTask.java:510)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
... 52 more
Caused by: com.android.ide.common.internal.LoggedErrorException: Failed to run c
ommand:
C:\Android\android-studio2\sdk\build-tools\android-4.4\dx.bat --dex --ou
tput E:\Backups\etc\TestProj2\Test2\build\libs\Test2-defaultFlavor-debug.dex E:\
Backups\etc\TestProj2\Test2\build\classes\defaultFlavor\debug E:\Backups\etc\Tes
tProj2\Test2\build\dependency-cache\defaultFlavor\debug
Error Code:
1
Output:
The filename, directory name, or volume label syntax is incorrect.

at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandL
ineRunner.java:98)
at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandL
ineRunner.java:69)
at com.android.builder.AndroidBuilder.convertByteCode(AndroidBuilder.jav
a:998)
at com.android.builder.AndroidBuilder$convertByteCode.call(Unknown Sourc
e)
at com.android.build.gradle.tasks.Dex.doFullTaskAction(Dex.groovy:55)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(In
crementalTask.groovy:96)
at org.gradle.util.JavaMethod.invoke(JavaMethod.java:62)
... 59 more


BUILD FAILED

Total time: 5.923 secs

之后,我得到这个错误:

Gradle: Execution failed for task ':Test2:dexDefaultFlavorDebug'.
> Could not call IncrementalTask.taskAction() on task ':Test2:dexDefaultFlavorDebug'

所以,看起来“文件名、目录名或卷标语法”有问题,但是什么文件呢?什么目录?

我猜这可能与分隔符有关,但我不确定,而且我对 gradle 的掌握很薄弱。

(我已将路径变量、JAVA_HOME 变量和 JDK_HOME 变量设置为指向我的 JDK 7_45 目录。我正在运行 Win 7。)

编辑:我的 Gradle 文件如下所示

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'

repositories {
mavenCentral()
}

android {
compileSdkVersion 17
buildToolsVersion "19.0.0"

defaultConfig {
minSdkVersion 17
targetSdkVersion 17
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}

dependencies {
}

最佳答案

终于解决了。我再次查看错误信息并尝试运行失败前的最后一条命令,例如:

C:\Android\android-studio2\sdk\build-tools\android-4.4\dx.bat --dex --ou
tput E:\Backups\etc\TestProj2\Test2\build\libs\Test2-defaultFlavor-debug.dex E:\
Backups\etc\TestProj2\Test2\build\classes\defaultFlavor\debug E:\Backups\etc\Tes
tProj2\Test2\build\dependency-cache\defaultFlavor\debug

这给出了“文件名、目录名或卷标语法不正确。”然后我去了 build-tools 文件夹并运行 dx.bat 没有 cmd-line args:

C:\Android\android-studio2\sdk\build-tools\android-4.4\dx.bat

还是报同样的错。所以我查看了文件内部并找到了这些行:

rem Check we have a valid Java.exe in the path.
set java_exe=
if exist "%~dp0..\tools\lib\find_java.bat" call "%~dp0..\tools\lib\find_java.bat"
if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat"
if not defined java_exe goto :EOF

所以我尝试从命令行运行 find_java.bat,但它什么也没返回

所以我用下面一行替换了上面几行:

set java_exe=C:\Windows\System32\java.exe

一切都开始工作了......

关于android - Gradle:文件名、目录名或卷标语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20168156/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com