Cordova构建失败

时间:2014-07-24 09:03:44

标签: android cordova

我是Cordova的新手,并按照本指南尝试了一个示例应用程序: http://cordova.apache.org/docs/en/3.5.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide

不幸的是,我在命令行中收到以下错误:

            Running command: G:\CordovaTest\hello\platforms\android\cordova\build.bat 
            Buildfile: G:\CordovaTest\hello\platforms\android\build.xml

            -set-mode-check:

            -set-debug-files:

            -check-env:
             [checkenv] Android SDK Tools Revision 23.0.2
             [checkenv] Installed at D:\adt-bundle-windows-x86_64-20140702\sdk

            -setup:
                 [echo] Project Name: HelloWorld
              [gettype] Project Type: Application

            -set-debug-mode:

            -debug-obfuscation-check:

            -pre-build:

            -build-setup:
            [getbuildtools] Using latest Build Tools: 20.0.0
                 [echo] Resolving Build Target for HelloWorld...
            [gettarget] Project Target:   Android 4.4.2
            [gettarget] API level:        19
                 [echo] ----------
                 [echo] Creating output directories if needed...
                [mkdir] Created dir: G:\CordovaTest\hello\platforms\android\ant-build\rsObj
                [mkdir] Created dir: G:\CordovaTest\hello\platforms\android\ant-build\rsLibs
                 [echo] ----------
                 [echo] Resolving Dependencies for HelloWorld...
            [dependency] Library dependencies:
            [dependency] 
            [dependency] ------------------
            [dependency] Ordered libraries:
            [dependency] 
            [dependency] ------------------
                 [echo] ----------
                 [echo] Building Libraries with 'debug'...

            nodeps:

            -set-mode-check:

            -set-debug-files:

            -check-env:
             [checkenv] Android SDK Tools Revision 23.0.2
             [checkenv] Installed at D:\adt-bundle-windows-x86_64-20140702\sdk

            -setup:
                 [echo] Project Name: CordovaLib
              [gettype] Project Type: Android Library

            -set-debug-mode:

            -debug-obfuscation-check:

            -pre-build:

            -build-setup:
            [getbuildtools] Using latest Build Tools: 20.0.0
                 [echo] Resolving Build Target for CordovaLib...
            [gettarget] Project Target:   Android 4.4.2
            [gettarget] API level:        19
                 [echo] ----------
                 [echo] Creating output directories if needed...
                 [echo] ----------
                 [echo] Resolving Dependencies for CordovaLib...
            [dependency] Library dependencies:
            [dependency] No Libraries
            [dependency] 
            [dependency] ------------------

            -code-gen:
            [mergemanifest] Found Deleted Target File
            [mergemanifest] Merging AndroidManifest files into one.
            [mergemanifest] Manifest merger disabled. Using project manifest only.
                 [echo] Handling aidl files...
                 [aidl] No AIDL files to compile.
                 [echo] ----------
                 [echo] Handling RenderScript files...
                 [echo] ----------
                 [echo] Handling Resources...
                 [aapt] Found new input file
                 [aapt] Generating resource IDs...
                 [echo] ----------
                 [echo] Handling BuildConfig class...
            [buildconfig] No need to generate new BuildConfig.

            -pre-compile:

            -compile:
                 [echo] Creating library output jar file...

            -post-compile:

            -obfuscate:

            -dex:
                 [echo] Library project: do not convert bytecode...

            -crunch:
               [crunch] Crunching PNG Files in source dir: G:\CordovaTest\hello\platforms\android\CordovaLib\res
               [crunch] To destination dir: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\res
               [crunch] Crunched 0 PNG files to update cache

            -package-resources:
                 [echo] Library project: do not package resources...

            -package:
                 [echo] Library project: do not package apk...

            -post-package:

            -do-debug:
                 [echo] Library project: do not create apk...
            [propertyfile] Updating property file: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\build.prop
            [propertyfile] Updating property file: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\build.prop
            [propertyfile] Updating property file: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\build.prop
            [propertyfile] Updating property file: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\build.prop

            -post-build:

            debug:

            -code-gen:
            [mergemanifest] Found Deleted Target File
            [mergemanifest] Merging AndroidManifest files into one.
            [mergemanifest] Manifest merger disabled. Using project manifest only.
                 [echo] Handling aidl files...
                 [aidl] No AIDL files to compile.
                 [echo] ----------
                 [echo] Handling RenderScript files...
                 [echo] ----------
                 [echo] Handling Resources...
                 [aapt] Found Deleted Target File
                 [aapt] Generating resource IDs...
                 [echo] ----------
                 [echo] Handling BuildConfig class...
            [buildconfig] Generating BuildConfig class.

            -pre-compile:
                 [echo] Set jars path to: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\classes.jar

            -compile:
                [javac] Compiling 3 source files to G:\CordovaTest\hello\platforms\android\ant-build\classes

            -post-compile:

            -obfuscate:

            -dex:
                  [dex] input: G:\CordovaTest\hello\platforms\android\ant-build\classes
                  [dex] input: G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\classes.jar
                  [dex] Pre-Dexing G:\CordovaTest\hello\platforms\android\CordovaLib\ant-build\classes.jar -> classes-c7d3e986ff339bb9d7b4b67df549a8b8.jar
                   [dx] 
                   [dx] trouble writing output: java.security.NoSuchAlgorithmException: SHA-1 MessageDigest not available

            BUILD FAILED
            D:\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\build.xml:892: The following error occurred whil
            e executing this line:
            D:\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\build.xml:894: The following error occurred whil
            e executing this line:
            D:\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\build.xml:906: The following error occurred whil
            e executing this line:
            D:\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\build.xml:283: null returned: 2

            Total time: 10 seconds
            Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,G:\CordovaTest\hello\platforms\android\b
            uild.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
            Command finished with error code 2: G:\CordovaTest\hello\platforms\android\cordova\build.bat
            Error: G:\CordovaTest\hello\platforms\android\cordova\build.bat: Command failed with exit code 2
                at ChildProcess.whenDone (C:\Users\IBM_ADMIN\AppData\Roaming\npm\node_modules\cordova\node_modul
            es\cordova-lib\src\cordova\superspawn.js:135:23)
                at ChildProcess.EventEmitter.emit (events.js:98:17)
                at maybeClose (child_process.js:743:16)
                at Process.ChildProcess._handle.onexit (child_process.js:810:5)

我使用的是windows7 64bit。我的env变量如下!

            D:\SDK7_64\bin;D:\SDK7_64\jre\bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows
            \System32\WindowsPowerShell\v1.0\;C:\Program Files\IBM\Infoprint Select;C:\Program Files\ThinkPad\Bl
            uetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\Program Files\Intel\WiFi\
            bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Lenovo\Access Connec
            tions\;C:\Program Files (x86)\IBM\Personal Communications\;C:\Program Files (x86)\IBM\Trace Facility
            \;D:\Program Files\IDM Computer Solutions\UltraEdit-32;D:\Program Files\nodejs\;D:\Program Files\Clo
            udFoundry;D:\Program Files\cURL\bin;D:\jq;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common F
            iles\Intel\WirelessCommon\;D:\Program Files\SSH Communications Security\SSH Secure Shell;C:\Users\IB
            M_ADMIN\AppData\Roaming\npm;D:\apache-ant-1.9.4\bin;D:\AndroidSDK\sdk\platform-tools;D:\AndroidSDK\s
            dk\tools

任何人都可以帮我这个吗?非常感谢你!

1 个答案:

答案 0 :(得分:0)

您是否曾阅读过复制到问题中的构建输出?

它包含通常输出错误消息的末尾:

  

[dx]写输出错误:java.security.NoSuchAlgorithmException:SHA-1 MessageDigest不可用

     

建立失败

这是因为构建失败而需要调查的错误消息。

接下来,我使用"SHA-1 MessageDigest not available"运行搜索,并在Stack Overflow上找到:

使用WWW搜索引擎可以找到包含此错误消息字符串的更多网页。

在阅读答案和其他一些网页后,我现在知道这个错误消息可能有几个不同的原因。您必须自己找出哪些原因导致构建中的错误消息。