Android Studio 在run时报的异常 Failed to run command file not found FileNotFoundException

Android Studio 在run时报的异常 Failed to run command file not found FileNotFoundException

在github上下载项目,导入后 有时不注意,在build完后,run时会报现个FileNotFoundException,会提示如下的错误:


Error:Execution failed for task ‘:sample:dexDebug’.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Program Files\Android\sdk\build-tools\21.1.2\dx.bat –dex –no-optimize –output D:\需要的文档\学习资料\xxx\sample\build\intermediates\dex\debug –input-list=D:\需要的文档\学习资料\xxx\sample\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: D:\闇?瑕佺殑鏂囨。\瀛︿範璧勬枡\js涓巜eb瀹夊叏浜や簰\xxx\sample\build\intermediates\classes\debug: file not found
at com.android.dex.util.FileUtils.readFile(FileUtils.java:51)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:169)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.io.FileNotFoundException: D:\闇?瑕佺殑鏂囨。\瀛︿範璧勬枡\js涓巜eb瀹夊叏浜や簰\xxx\sample\build\intermediates\pre-dexed\debug\classes-6bafb5ea8fc86808334b6373daacdc92babdec8a.jar (系统找不到指定的路径。)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:220)
at java.util.zip.ZipFile.(ZipFile.java:150)
at java.util.zip.ZipFile.(ZipFile.java:164)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.io.FileNotFoundException: D:\闇?瑕佺殑鏂囨。\瀛︿範璧勬枡\js涓巜eb瀹夊叏浜や簰\xxx\sample\build\intermediates\pre-dexed\debug\gson-2.3-317f284ee257b9e36af74bb2d07d373f5b8009da.jar (系统找不到指定的路径。)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:220)
at java.util.zip.ZipFile.(ZipFile.java:150)
at java.util.zip.ZipFile.(ZipFile.java:164)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
3 errors; aborting


上面在run时报的异常 Failed to run command file not found,文件居然找不到(FileNotFoundException),,找不到啊。。。
而路径中有乱码了,应该可能是中文乱码的问题。
将project 空间路径转成 英文的,果然发现OK。。


结论:在Android studio中project 工作空间路径不要含有中文,否则很容易会报FileNotFoundException. 这点eclipse是支持中文的。

你可能感兴趣的:(android,异常)