Cordova Build命令不再适用于android

时间:2014-02-17 23:31:57

标签: android cordova cordova-3

这是我得到的,当我尝试构建cordova应用程序时从命令行输出:

C:\wamp\tests\cortest>cordova build
Generating config.xml from defaults for platform "android"
Preparing android project
Compiling app on platform "android" via command "cmd" /c C:\wamp\te
sts\cortest\platforms\android\cordova\build
Error: An error occurred while building the android project.Error executing "ant
 debug -f "C:\wamp\tests\cortest\platforms\android\build.xml"":
BUILD FAILED
C:\Program Files (x86)\Android\android-studio\sdk\tools\ant\build.xml:601: The f
ollowing error occurred while executing this line:
C:\Program Files (x86)\Android\android-studio\sdk\tools\ant\build.xml:720: The f
ollowing error occurred while executing this line:
C:\Program Files (x86)\Android\android-studio\sdk\tools\ant\build.xml:734: Compi
le failed; see the compiler error output for details.

Total time: 1 second


    at ChildProcess.<anonymous> (C:\Users\John\AppData\Roaming\npm\node_modules\
cordova\src\compile.js:65:22)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

这是我的配置文件:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foundation.app" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>FoundationMobile</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>

我有Windows 7,64位。不确定是否重要。知道发生了什么,为什么我不能再建造它了?在我用Android管理器更新Android SDK之前它正在工作。

提前非常感谢你!

在2014年2月23日添加,项目和sdk路径现在不同了,因为我重新安装了sdk,并创建了新项目,但错误是一样的。

C:\ wamp \ tests \ cordova-test&gt; cordova -d build     用于“android”的cordova库已经存在。无需下载。继续。     从平台“android”的默认值生成config.xml     调用plugman.prepare for platform“android”     准备android项目     处理插件的配置更改。     迭代已安装的插件:[]     写出cordova_plugins.js ......     将Android应用程序名称写成“CordovaTest”     将Android软件包名称写成“com.foundation.app”     通过命令“cmd”/ c C:\ wamp \ te在平台“android”上编译应用程序     STS \科尔多瓦测试\平台\机器人\科尔多瓦\构建     exec:ant clean -f“C:\ wamp \ tests \ cordova-test \ platforms \ android \ bu     ild.xml“

[ 'ant clean -f "C:\\wamp\\tests\\cordova-test\\platforms\\androi
d\\build.xml"',
  null,
  'Buildfile: C:\\wamp\\tests\\cordova-test\\platforms\\android\\
build.xml\r\n\r\n-check-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\
n [checkenv] Installed at C:\\adt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-se
tup:\r\n     [echo] Project Name: CordovaTest\r\n  [gettype] Project Type: Appli
cation\r\n\r\n-pre-clean:\r\n\r\nclean:\r\n   [delete] Deleting directory C:\\wam
p\\tests\\cordova-test\\platforms\\android\\bin\r\n   [delete] D
eleting directory C:\\wamp\\tests\\cordova-test\\platforms\\andro
id\\gen\r\n[getlibpath] Library dependencies:\r\n[getlibpath] \r\n[getlibpath] -
-----------------\r\n[getlibpath] Ordered libraries:\r\n\r\nnodeps:\r\n\r\n-chec
k-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\n [checkenv] Installed
 at C:\\adt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-setup:\r\n     [echo] Pr
oject Name: CordovaLib\r\n  [gettype] Project Type: Android Library\r\n\r\n-pre-
clean:\r\n\r\nclean:\r\n   [delete] Deleting directory C:\\wamp\\
tests\\cordova-test\\platforms\\android\\CordovaLib\\bin\r\n   [delete] Deleting
 directory C:\\wamp\\tests\\cordova-test\\platforms\\android\\Cor
dovaLib\\gen\r\n\r\nBUILD SUCCESSFUL\r\nTotal time: 0 seconds\r\n',
  '' ]

exec: ant debug -f "C:\wamp\tests\cordova-test\platforms\android\bu
ild.xml"

[ 'ant debug -f "C:\\wamp\\tests\\cordova-test\\platforms\\androi
d\\build.xml"',
  { [Error: Command failed:
  BUILD FAILED
  C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:601: The followi
ng error occurred while executing this line:
  C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:720: The followi
ng error occurred while executing this line:
  C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:734: Compile fai
led; see the compiler error output for details.

  Total time: 2 seconds
  ] killed: false, code: 1, signal: null },
  'Buildfile: C:\\wamp\\tests\\cordova-test\\platforms\\android\\
build.xml\r\n\r\n-set-mode-check:\r\n\r\n-set-debug-files:\r\n\r\n-check-env:\r\
n [checkenv] Android SDK Tools Revision 22.3.0\r\n [checkenv] Installed at C:\\a
dt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-setup:\r\n     [echo] Project Nam
e: CordovaTest\r\n  [gettype] Project Type: Application\r\n\r\n-set-debug-mode:\
r\n\r\n-debug-obfuscation-check:\r\n\r\n-pre-build:\r\n\r\n-build-setup:\r\n[get
buildtools] Using latest Build Tools: 19.0.2\r\n     [echo] Resolving Build Targ
et for CordovaTest...\r\n[gettarget] Project Target:   Android 4.4.2\r\n[gettarg
et] API level:        19\r\n     [echo] ----------\r\n     [echo] Creating outpu
t directories if needed...\r\n    [mkdir] Created dir: C:\\wamp\\root\\
tests\\cordova-test\\platforms\\android\\bin\r\n    [mkdir] Created dir: C:\\wamp
\\tests\\cordova-test\\platforms\\android\\bin\\res\r\n    [mkdi
r] Created dir: C:\\wamp\\tests\\cordova-test\\platforms\\android
\\bin\\rsObj\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordova
-test\\platforms\\android\\bin\\rsLibs\r\n    [mkdir] Created dir: C:\\wamp\\tes
ts\\cordova-test\\platforms\\android\\gen\r\n    [mkdir] Created
dir: C:\\wamp\\tests\\cordova-test\\platforms\\android\\bin\\clas
ses\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordova-test\\pl
atforms\\android\\bin\\dexedLibs\r\n     [echo] ----------\r\n     [echo] Resolv
ing Dependencies for CordovaTest...\r\n[dependency] Library dependencies:\r\n[de
pendency] \r\n[dependency] ------------------\r\n[dependency] Ordered libraries:
\r\n[dependency] \r\n[dependency] ------------------\r\n     [echo] ----------\r
\n     [echo] Building Libraries with \'debug\'...\r\n\r\nnodeps:\r\n\r\n-set-mo
de-check:\r\n\r\n-set-debug-files:\r\n\r\n-check-env:\r\n [checkenv] Android SDK
 Tools Revision 22.3.0\r\n [checkenv] Installed at C:\\adt-bundle-windows-x86_64
-20131030\\sdk\r\n\r\n-setup:\r\n     [echo] Project Name: CordovaLib\r\n  [gett
ype] Project Type: Android Library\r\n\r\n-set-debug-mode:\r\n\r\n-debug-obfusca
tion-check:\r\n\r\n-pre-build:\r\n\r\n-build-setup:\r\n[getbuildtools] Using lat
est Build Tools: 19.0.2\r\n     [echo] Resolving Build Target for CordovaLib...\
r\n[gettarget] Project Target:   Android 4.4.2\r\n[gettarget] API level:
19\r\n     [echo] ----------\r\n     [echo] Creating output directories if neede
d...\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordova-test\\p
latforms\\android\\CordovaLib\\bin\r\n    [mkdir] Created dir: C:\\wamp\\tests
\\cordova-test\\platforms\\android\\CordovaLib\\bin\\res\r\n    [mk
dir] Created dir: C:\\wamp\\tests\\cordova-test\\platforms\\andro
id\\CordovaLib\\bin\\rsObj\r\n    [mkdir] Created dir: C:\\wamp\\root\\
tests\\cordova-test\\platforms\\android\\CordovaLib\\bin\\rsLibs\r\n    [mkdir]
Created dir: C:\\wamp\\tests\\cordova-test\\platforms\\android\\C
ordovaLib\\gen\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordo
va-test\\platforms\\android\\CordovaLib\\bin\\classes\r\n    [mkdir] Created dir
: C:\\wamp\\tests\\cordova-test\\platforms\\android\\CordovaLib\\
bin\\dexedLibs\r\n     [echo] ----------\r\n     [echo] Resolving Dependencies f
or CordovaLib...\r\n[dependency] Library dependencies:\r\n[dependency] No Librar
ies\r\n[dependency] \r\n[dependency] ------------------\r\n\r\n-code-gen:\r\n[me
rgemanifest] Merging AndroidManifest files into one.\r\n[mergemanifest] Manifest
 merger disabled. Using project manifest only.\r\n     [echo] Handling aidl file
s...\r\n     [aidl] No AIDL files to compile.\r\n     [echo] ----------\r\n
[echo] Handling RenderScript files...\r\n     [echo] ----------\r\n     [echo] H
andling Resources...\r\n     [aapt] Generating resource IDs...\r\n     [echo] --
--------\r\n     [echo] Handling BuildConfig class...\r\n[buildconfig] Generatin
g BuildConfig class.\r\n\r\n-pre-compile:\r\n\r\n-compile:\r\n    [javac] Compil
ing 73 source files to C:\\wamp\\tests\\cordova-test\\platforms\\
android\\CordovaLib\\bin\\classes\r\n    [javac] C:\\wamp\\root\\tests\
\cordova-test\\platforms\\android\\CordovaLib\\src\\com\\squareup\\okhttp\\inter
nal\\http\\HttpEngine.java:95: error: cannot access RouteSelector\r\n    [javac]
   protected RouteSelector routeSelector;\r\n    [javac]             ^\r\n    [j
avac]   bad source file: C:\\wamp\\tests\\cordova-test\\platforms
\\android\\CordovaLib\\src\\com\\squareup\\okhttp\\internal\\http\\RouteSelector
.java\r\n    [javac]     file does not contain class com.squareup.okhttp.interna
l.http.RouteSelector\r\n    [javac]     Please remove or make sure it appears in
 the correct subdirectory of the sourcepath.\r\n',
  '\r\nBUILD FAILED\r\nC:\\adt-bundle-windows-x86_64-20131030\\sdk\\tools\\ant\\
build.xml:601: The following error occurred while executing this line:\r\nC:\\ad
t-bundle-windows-x86_64-20131030\\sdk\\tools\\ant\\build.xml:720: The following
error occurred while executing this line:\r\nC:\\adt-bundle-windows-x86_64-20131
030\\sdk\\tools\\ant\\build.xml:734: Compile failed; see the compiler error outp
ut for details.\r\n\r\nTotal time: 2 seconds\r\n' ]

Error executing "ant debug -f "C:\wamp\tests\cordova-test\platforms
\android\build.xml"":
BUILD FAILED
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:601: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:720: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:734: Compile faile
d; see the compiler error output for details.

Total time: 2 seconds


child_process.spawn(cmd,[/c, C:\wamp\tests\cordova-test\platforms\a
ndroid\cordova\build]) = 2
Error: An error occurred while building the android project.Error executing "ant
 debug -f "C:\wamp\tests\cordova-test\platforms\android\build.xml""
:
BUILD FAILED
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:601: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:720: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:734: Compile faile
d; see the compiler error output for details.

Total time: 2 seconds


    at ChildProcess.<anonymous> (C:\Users\Ivan\AppData\Roaming\npm\node_modules\
cordova\src\compile.js:65:22)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

C:\wamp\tests\cordova-test>

4 个答案:

答案 0 :(得分:1)

我的笔记本电脑也是Windows 7 64位,我解决了这个问题,做了以下

  • http://ant.apache.org/
  • 下载最新版本的ANT
  • 解压缩并将文件放在磁盘中的正确位置
  • 将绝对方向复制到 <{em> Windows PATH中 bin ANT 文件夹变量

    即。在我的情况下。的 D:\apache-ant-1.9.4\bin

  • 在CMD中检查 ant -version 是否有效。这应该显示下载的ANT的版本(如果不工作,请再次检查PATH变量,然后再执行下一步)

  • 在CMD中转到cordova项目文件夹并再次运行 cordova build android 。如果上一步工作正常,您应该毫无问题地构建项目。如果您的项目是离子项目,则应在此处 ionic build android 运行,结果应该相同。

我希望这有帮助。

问候!

答案 1 :(得分:1)

尝试获取最新版本的Android平台。

cordova platform update android

它为我工作

答案 2 :(得分:0)

在您的终端中尝试ant -v,并确保它高于1.8。科尔多瓦需要这样做。对于Ant,Android-SDK /工具和Android-SDK / platformtools

,检查路径也是正确的

要调试确切问题,请尝试$Cordova build android --verbose

答案 3 :(得分:0)

问题出现在环境变量路径中,ANDROID_HOME指向:&#34; C:\ Program Files(x86)\ Android \ android-studio \ sdk&#34;,我刚刚添加了一个PROGRAM_FILES_86指向:C :\ Program Files(x86)并使用PROGRAM_FILES_86变量再次设置ANDROID_HOME路径。这解决了这个问题。