Cordova编译Android 22 以上版本,中文目录出错问题的解决办法

原创 2016年01月07日 11:02:41

如果用corodva编译工程,并且工程是中文名,在windows下会报错,类似如下贴子

http://www.lai18.com/content/1316143.html

找遍网络没发现处理方法,细看后解决,其实原理很简单,android的文件都按照utf-8处理,但windows下的java默认是gbk,强制指定一下字符集即可。


自己的错误:

2016-01-07 10:49:50 :preDexDebug
2016-01-07 10:49:51 
2016-01-07 10:49:51 UNEXPECTED TOP-LEVEL EXCEPTION:
2016-01-07 10:49:51 java.lang.RuntimeException: D:\Work\SVN\Native\鎴戠殑宸ョ▼\build\src\platforms\android\build\intermediates\classes\debug: file not found
2016-01-07 10:49:51 at com.android.dex.util.FileUtils.readFile(FileUtils.java:51)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:169)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processOne(Main.java:672)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.run(Main.java:277)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.main(Main.java:245)
2016-01-07 10:49:51 at com.android.dx.command.Main.main(Main.java:106)
2016-01-07 10:49:51 
2016-01-07 10:49:51 UNEXPECTED TOP-LEVEL EXCEPTION:
2016-01-07 10:49:51 java.io.FileNotFoundException: D:\Work\SVN\Native\鎴戠殑宸ョ▼\build\src\platforms\android\build\intermediates\pre-dexed\debug\classes-bc78ef27922ebddaf5ac264df598226800028ed8.jar (系统找不到指定的路径。)
2016-01-07 10:49:51 at java.util.zip.ZipFile.open(Native Method)
2016-01-07 10:49:51 at java.util.zip.ZipFile.<init>(ZipFile.java:215)
2016-01-07 10:49:51 at java.util.zip.ZipFile.<init>(ZipFile.java:145)
2016-01-07 10:49:51 at java.util.zip.ZipFile.<init>(ZipFile.java:159)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processOne(Main.java:672)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.run(Main.java:277)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.main(Main.java:245)
2016-01-07 10:49:51 at com.android.dx.command.Main.main(Main.java:106)
2016-01-07 10:49:51 2 errors; aborting
2016-01-07 10:49:51 
2016-01-07 10:49:51 FAILURE: Build failed with an exception.
2016-01-07 10:49:51 
2016-01-07 10:49:51 * What went wrong:
2016-01-07 10:49:51 Execution failed for task ':dexDebug'.
2016-01-07 10:49:51 > com.android.ide.common.internal.LoggedErrorException: Failed to run command:
2016-01-07 10:49:51 D:\Work\BeX5\tools\adt-sdk\build-tools\23.0.2\dx.bat --dex --no-optimize --output D:\Work\SVN\Native\我的工程\build\src\platforms\android\build\intermediates\dex\debug --input-list=D:\Work\SVN\Native\我的工程\build\src\platforms\android\build\intermediates\tmp\dex\debug\inputList.txt
2016-01-07 10:49:51 Error Code:
2016-01-07 10:49:51 1
2016-01-07 10:49:51 Output:
2016-01-07 10:49:51
2016-01-07 10:49:51 UNEXPECTED TOP-LEVEL EXCEPTION:
2016-01-07 10:49:51 java.lang.RuntimeException: D:\Work\SVN\Native\鎴戠殑宸ョ▼\build\src\platforms\android\build\intermediates\classes\debug: file not found
2016-01-07 10:49:51 at com.android.dex.util.FileUtils.readFile(FileUtils.java:51)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:169)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processOne(Main.java:672)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.run(Main.java:277)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.main(Main.java:245)
2016-01-07 10:49:51 at com.android.dx.command.Main.main(Main.java:106)
2016-01-07 10:49:51
2016-01-07 10:49:51 UNEXPECTED TOP-LEVEL EXCEPTION:
2016-01-07 10:49:51 java.io.FileNotFoundException: D:\Work\SVN\Native\鎴戠殑宸ョ▼\build\src\platforms\android\build\intermediates\pre-dexed\debug\classes-bc78ef27922ebddaf5ac264df598226800028ed8.jar (系统找不到指定的路径。)
2016-01-07 10:49:51 at java.util.zip.ZipFile.open(Native Method)
2016-01-07 10:49:51 at java.util.zip.ZipFile.<init>(ZipFile.java:215)
2016-01-07 10:49:51 at java.util.zip.ZipFile.<init>(ZipFile.java:145)
2016-01-07 10:49:51 at java.util.zip.ZipFile.<init>(ZipFile.java:159)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
2016-01-07 10:49:51 at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processOne(Main.java:672)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.run(Main.java:277)
2016-01-07 10:49:51 at com.android.dx.command.dexer.Main.main(Main.java:245)
2016-01-07 10:49:51 at com.android.dx.command.Main.main(Main.java:106)
2016-01-07 10:49:51 2 errors; aborting
2016-01-07 10:49:51 
2016-01-07 10:49:51 
2016-01-07 10:49:51 * Try:
2016-01-07 10:49:51 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
2016-01-07 10:49:51 :dexDebug FAILED
2016-01-07 10:49:51 
2016-01-07 10:49:51 BUILD FAILED


根据提示把

D:\Work\BeX5\tools\adt-sdk\build-tools\23.0.2\dx.bat

中的最后一行改为

call "%java_exe%" %javaOpts% -Dfile.encoding=UTF-8 -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%

增加了-Dfile.encoding=UTF-8 这个强制指定字符集,本质原因是中间文件dex\debug\inputList.txt是utf-8格式

cordova创建android项目并编译

cordova建安卓项目; cordova编译项目; android apk签名; android apk覆盖安装问题;...

在 Cordova/Phonegap for Android 中包含中文文件名的页面

在 Cordova/Phonegap for Android 中包含中文文件名的页面 本贴首发于:http://xuekaiyuan.com/forum.php?mod=viewthread&tid...

dx使用出现的错误总结

使用dx的各种悲剧错误,一直一直搞啊搞,搞了三天之后才把这么个小错误搞定 做程序员不易浮躁啊,还有就是要真的是要锲而不舍啊!!!!!!!   错误一: UNEXPECTED TOP-LEVEL EXC...

你想要的这都有-Android文件工具类FileUtils

包含所有关于文件处理的工具类/** * 对文件处理的工具类 */ public class FileUtils { /** * 获取可以使用的缓存目录(默认目录名...

Android Stuido 中 Error:'app:transformClassesWithDexForDebug'. > Unable to pre-dex 的解决方法

总结一下,初次使用Android Studio时遇到的一些问题。主要有以下几个问题:1. Java版本的问题出现问题的关键字:javaMaxHeapSize 可参考博客:http://blog.c...

使用android stuido 编译项目时,项目的路径包含中文无法编译成功解决办法

1、使用android stuido 编译项目时,项目的路径包含中文无法编译成功 Your project path contains non-ASCII characters. ...

Android Studio项目路径中包含中文字符无法编译问题报错Your project path contains non-ASCII characters.

解决Android Studio不支持中文目录的问题 Android Studio 报下面的错误 Error:(1, 0) Your project path contains non-ASCII c...

android编译build-cache路径问题引起编译失败

android studio和gradle 编译都会报这个错 AAPT err(Facade for 1763883654): \\?\C:\Users\张XX\.android\build...

cordova错误总结

1,shell.js: internal error Error: EXDEV, cross-device link not permittedcordova plugin add xx时会出现:sh...

AIX6.1 下构建 GCC/G++ 编译环境

网络上关于AIX安装gcc/g++文档很多,不过大多数都基于5.3,试图在一台AIX6.1安装,安装过程少不了插曲,记录供查阅。 1.  下载gcc/g++ for aix 6.1版本。IBM官网提...
  • wisheen
  • wisheen
  • 2012年05月09日 09:21
  • 2130
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Cordova编译Android 22 以上版本,中文目录出错问题的解决办法
举报原因:
原因补充:

(最多只允许输入30个字)