首页 > 代码库 > [Blackberry]Bug_build时出错_java build 编码格式问题及解决办法

[Blackberry]Bug_build时出错_java build 编码格式问题及解决办法

  使用phonegap(cordova),在开发完ios/android版本后,近几天想弄一个黑莓的版本,故去搭建phonegap的黑莓开发环境,按照官方文档 http://docs.phonegap.com/en/2.2.0/guide_getting-started_blackberry_index.md.html#Getting%20Started%20with%20Blackberry 一步步把环境搭建好之后,兴奋地急着想看看运行的效果,但是在build/load-simulator时就被打击得不轻,出现了如下错误(错误信息摘自http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece7631043973b5e16c1743ca085482281cd1f84642c101a39feee677f5746cea7263a5df83c0fa8814a6f684275aa9a9ede4fdeb9c27b2e83206474188c42069644ef9d49739671cd0cb2f34cf0bb806dc0ecc5d2af4353bd44040ac2b7cd4d00659d25b6436da2fdc414025e60adea4172fe292777cc7219a14689b0652e47cae1dc2c5bc45bc76061c6f26aef634ea212d4081c5553a13cf64e0a7827e13f30f8352a05e2ac1db93d783075e119eeef96f6fc49fccbea468ffbbbf77cd133&p=b4759a46dc8912a05beb8c60454980&newp=8b2a9643ba934eac52aedf3953548a231615d70e37d3d579&user=baidu&fm=sc&query=decodingMap%2Eput+extension%5Cblackberry%5Ccommon%5Cutil%5CURLDecoder%2Ejava&qid=d153fa8f00edf937&p1=1):

 

=========================================================

 

*D:\Workspace\sample>ant blackberry load-simulator* 

Buildfile: D:\Workspace\sample\build.xml 

blackberry: 

load-simulator: 

generate-cod-name: 

     [echo] Generated name: CordovaSample.cod 

clean: 

   [delete] Deleting directory D:\Workspace\sample\build 

package-app: 

    [mkdir] Created dir: D:\Workspace\sample\build\widget 

     [copy] Copying 8 files to D:\Workspace\sample\build\widget 

      [zip] Building zip: D:\Workspace\sample\build\CordovaSample.zip 

build: 

     [exec] [INFO]       Parsing command line options 

     [exec] [INFO]       Parsing bbwp.properties 

     [exec] [INFO]       Validating application archive 

     [exec] [INFO]       Parsing config.xml 

     [exec] [WARNING]    Failed to find the <author> element 

     [exec] [INFO]       Populating application source 

     [exec] [INFO]       Compiling BlackBerry WebWorks application 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:139: 错误: 未结束的字符串文字 

     [exec]         decodingMap.put( "%80", "? ); 

     [exec]                                 ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:139: 错误: 需要‘;‘ 

     [exec]         decodingMap.put( "%80", "? ); 

     [exec]                                      ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:140: 错误: 非法的表达式开始 

     [exec]         decodingMap.put( "%81", " " ); 

     [exec]                    ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:140: 错误: 需要‘;‘ 

     [exec]         decodingMap.put( "%81", " " ); 

     [exec]                        ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:141: 

错误: 未结束的字符串文字 

     [exec]         decodingMap.put( "%82", "? ); 

     [exec]                                 ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:141: 错误: 需要‘;‘ 

     [exec]         decodingMap.put( "%82", "? ); 

     [exec]                                      ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:142: 错误: 非法的表达式开始 

     [exec]         decodingMap.put( "%83", "? ); 

     [exec]                    ^ 

.......................................... 

.......................................... 

.......................................... 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:181: 错误: 未结束的字符串文字 

     [exec]         decodingMap.put( "%AA", "? ); 

     [exec]                                 ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:182:错误: 未结束的字符串文字 

     [exec]         decodingMap.put( "%AB", "? ); 

     [exec]                                 ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:182:错误: 需要‘;‘ 

     [exec]         decodingMap.put( "%AB", "? ); 

     [exec]                                      ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:183: 错误: 非法的表达式开始 

     [exec]         decodingMap.put( "%AC", "? ); 

     [exec]                    ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:183: 

错误: 需要‘;‘ 

     [exec]         decodingMap.put( "%AC", "? ); 

     [exec]                        ^ 

     [exec] C:\Documents and Settings\Administrator\Local 

Settings\Temp\widgetGen.165781651338115655203.tmp\extension\blackberry\common\util\URLDecoder.java:183: 错误: 未结束的字符串文字 

     [exec]         decodingMap.put( "%AC", "? ); 

     [exec]                                 ^ 

     [exec] 100 个错误 

     [exec] Error!: Error: java compiler failed: D:\Program Files\Java\jdk1.7.0_03\bin\javac.exe 

@C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\rapc_1c33ffa2.d ... 

     [exec] [ERROR]      RAPC exception occurred 

load-simulator: 

     [echo] Simulator directory=D:\Program Files\Research In 

Motion\BlackBerry WebWorks SDK 2.3.1.5\simpack\7.0.0.318 

     [echo] Simulator directory=D:\Program Files\Research In 

Motion\BlackBerry WebWorks SDK 2.3.1.5\simpack\7.0.0.318 

     [echo] Simulator executable=D:\Program Files\Research In 

Motion\BlackBerry WebWorks SDK 2.3.1.5\simpack\7.0.0.318/9930.bat 

     [echo] Closing all running simulators... 

     [exec] No sessions currently running. 

     [echo] MDS directory=D:\Program Files\Research In Motion\BlackBerry 

WebWorks SDK 2.3.1.5/mds 

BUILD FAILED 

D:\Workspace\sample\build.xml:33: The following error occurred while 

executing this line: 

D:\Workspace\sample\blackberry.xml:123: 

D:\Workspace\sample\build\StandardInstall does not exist. 

*机器环境:* 

*OS- Windows XP(Chinese)* 

*Java- jdk1.6.0_05* 

*Ant-apache-ant-1.8.1* 

*BlackBerry WebWorks SDK 2.3.1.5* 

*Cordova-1.7.0* 

 

===============================================================

 
最终在:
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/is-webwork-sdk2-3-ok-I-got-error-even-compiling-helloworld-app/td-p/1538121
http://blogs.embarcadero.com/teamj/2012/04/02/2992/
找到答案。
 
 
问题的根源来自BlackBerry WebWorks SDK:
SDK的安装目录下的URLDecoder.java乱码,目录如:D:\dev\Research In Motion\BlackBerry WebWorks SDK 2.3.1.5\ext\common\blackberry\common\util\URLDecoder.java
而终端打印的一堆出错信息都是表象,C:\Documents and Settings\Administrator\Local 
Settings\Temp里java文件都是来自sdk,所以我们只要把sdk下的URLDecoder.java进行下处理那可:
在终端cd到sdk安装目录,并进入URLDecoder.java所有目录,执行如下命令。
 

D:\dev\Research In Motion\BlackBerry WebWorks SDK 2.3.1.5\ext\common\blackberry\common\util>native2ascii -encoding ISO-8859-1 URLDecoder.java URLDecoder.java_Unicode

D:\dev\Research In Motion\BlackBerry WebWorks SDK 2.3.1.5\ext\common\blackberry\common\util>rename URLDecoder.java URLDecoder.java_bak

D:\dev\Research In Motion\BlackBerry WebWorks SDK 2.3.1.5\ext\common\blackberry\common\util>rename URLDecoder.java_Unicode URLDecoder.java

 

结果:

编译并打包成功,但是仍然会弹出 “Oh Snap! Build request failed with message: undefined“ 警告框,但不妨碍build和package,在相应Output路径下可以看到OTAInstall和StandardInstall两个手机端可执行文件以及.zip打包文件。