Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

android - Gradle: The filename, directory name, or volume label syntax is incorrect

I've installed and setup the latest version of Android Studio (0.3.6, nov 14 release) but upon trying to build my project (a bare-bones hello world project made with the Android Studio new project wizard) I get the following error:

E:BackupsetcTestProj2>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:Androidandroid-studio2sdkuild-toolsandroid-4.4dx.bat --dex --ou
tput E:BackupsetcTestProj2Test2uildlibsTest2-defaultFlavor-debug.dex E:
BackupsetcTestProj2Test2uildclassesdefaultFlavordebug E:BackupsetcTes
tProj2Test2uilddependency-cachedefaultFlavordebug
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

Following that, I get this error:

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

So, it looks like something is wrong with the "The filename, directory name, or volume label syntax" but what file? What directory?

I'm guessing it might be something about the separator characters, but I'm not sure and my grasp of gradle is quite weak.

(I have set the path variable, JAVA_HOME variable and JDK_HOME variable to point to my JDK 7_45 directory. I'm running Win 7.)

Edit: My Gradle file looks like this

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 {
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally solved it. I looked at the error message again and tried to run the last command before failure, e.g.:

C:Androidandroid-studio2sdkuild-toolsandroid-4.4dx.bat --dex --ou
tput E:BackupsetcTestProj2Test2uildlibsTest2-defaultFlavor-debug.dex E:
BackupsetcTestProj2Test2uildclassesdefaultFlavordebug E:BackupsetcTes
tProj2Test2uilddependency-cachedefaultFlavordebug

This gave the "The filename, directory name, or volume label syntax is incorrect." So then I went to the build-tools folder and ran dx.bat with no cmd-line args:

C:Androidandroid-studio2sdkuild-toolsandroid-4.4dx.bat

And still got the same error. So I took a look inside the file and found these lines:

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

So I tried running find_java.bat from the command line and it returned nothing.

So I replaced the above lines with the below one:

set java_exe=C:WindowsSystem32java.exe

And everything started working...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...