简体   繁体   English

Cordova 4.1.2 CLI Android Build Fail Windows

[英]Cordova 4.1.2 CLI Android Build Fail Windows

I am trying to install and work on cordova for the the first time. 我正在尝试第一次安装和使用cordova。 I got through all the installation steps on the cordova apache page. 我完成了cordova apache页面上的所有安装步骤。 However, I get to the point where I need to build an android app and it never works. 但是,我到了需要构建一个Android应用程序的地步,它永远不会起作用。 I get the following error (which seems to be a frequent error to cordova first-timers but no helpful review on the matter) 我收到以下错误(这似乎是第一次使用cordova的常见错误,但对此事没有任何有用的评论)

The identifying error lines are: 识别错误行是:

Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\wamp\www\hello\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:\wamp\www\hello\platforms\android\cordova\build.bat: Command failed with exit code 8
    at ChildProcess.whenDone (C:\Users\Mina\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)

Here is the full cordova dump 这是完整的科尔多瓦转储

 Running command: C:\\wamp\\www\\hello\\platforms\\android\\cordova\\build.bat Buildfile: C:\\wamp\\www\\hello\\platforms\\android\\build.xml -set-mode-check: -set-debug-files: -check-env: [checkenv] Android SDK Tools Revision 24.0.2 [checkenv] Installed at C:\\Program Files (x86)\\Android\\android-sdk -setup: [echo] Project Name: CordovaApp [gettype] Project Type: Application -set-debug-mode: -debug-obfuscation-check: -pre-build: -build-setup: [getbuildtools] Using latest Build Tools: 21.1.2 [echo] Resolving Build Target for CordovaApp... [gettarget] Project Target: Android 4.4.2 [gettarget] API level: 19 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: C:\\wamp\\www\\hello\\platforms\\android\\ant-build\\rsObj [mkdir] Created dir: C:\\wamp\\www\\hello\\platforms\\android\\ant-build\\rsLibs [echo] ---------- [echo] Resolving Dependencies for CordovaApp... [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 24.0.2 [checkenv] Installed at C:\\Program Files (x86)\\Android\\android-sdk -setup: [echo] Project Name: CordovaApp [gettype] Project Type: Android Library -set-debug-mode: -debug-obfuscation-check: -pre-build: -build-setup: [getbuildtools] Using latest Build Tools: 21.1.2 [echo] Resolving Build Target for CordovaApp... [gettarget] Project Target: Android 4.4.2 [gettarget] API level: 19 [echo] ---------- [echo] Creating output directories if needed... [echo] ---------- [echo] Resolving Dependencies for CordovaApp... [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: C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\res [crunch] To destination dir: C:\\wamp\\www\\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: C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\ant-build\\build.prop [propertyfile] Updating property file: C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\ant-build\\build.prop [propertyfile] Updating property file: C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\ant-build\\build.prop [propertyfile] Updating property file: C:\\wamp\\www\\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: C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\ant-build\\classes.jar -compile: [javac] Compiling 3 source files to C:\\wamp\\www\\hello\\platforms\\android\\ant-build\\classes [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. [javac] 3 warnings -post-compile: -obfuscate: -dex: [dex] input: C:\\wamp\\www\\hello\\platforms\\android\\ant-build\\classes [dex] input: C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\ant-build\\classes.jar [dex] Using Pre-Dexed classes-d5034d149c5e3b24847cc18212597ab2.jar <- C:\\wamp\\www\\hello\\platforms\\android\\CordovaLib\\ant-build\\classes.jar [dex] Found Deleted Target File [dex] Converting compiled files and external libraries into C:\\wamp\\www\\hello\\platforms\\android\\ant-build\\classes.dex... [dx] Merged dex A (7 defs/2.2KiB) with dex B (209 defs/316.7KiB). Result is 216 defs/388.2KiB. Took 0.2s -crunch: [crunch] Crunching PNG Files in source dir: C:\\wamp\\www\\hello\\platforms\\android\\res [crunch] To destination dir: C:\\wamp\\www\\hello\\platforms\\android\\ant-build\\res [crunch] Crunched 0 PNG files to update cache -package-resources: [aapt] Creating full resource package... -package: [apkbuilder] Current build type is different than previous build: forced apkbuilder run. [apkbuilder] Creating CordovaApp-debug-unaligned.apk and signing it with a debug key... BUILD FAILED C:\\Program Files (x86)\\Android\\android-sdk\\tools\\ant\\build.xml:962: The following error occurred while executing this line: C:\\Program Files (x86)\\Android\\android-sdk\\tools\\ant\\build.xml:973: The following error occurred while executing this line: C:\\Program Files (x86)\\Android\\android-sdk\\tools\\ant\\build.xml:312: com.android.sdklib.build.ApkCreationException: Debug Certificate expired on 5/6/13 5:04 PM at com.android.sdklib.build.ApkBuilder.getDebugKey(ApkBuilder.java:285) at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:392) at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:334) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at com.android.ant.IfElseTask.execute(IfElseTask.java:124) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at com.android.ant.IfElseTask.execute(IfElseTask.java:124) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.apache.tools.ant.Main.runBuild(Main.java:851) at org.apache.tools.ant.Main.startAnt(Main.java:235) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) Total time: 6 seconds C:\\wamp\\www\\hello\\platforms\\android\\cordova\\node_modules\\q\\q.js:126 throw e; ^ Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\\wamp\\www\\hello\\platforms\\android\\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen Error: C:\\wamp\\www\\hello\\platforms\\android\\cordova\\build.bat: Command failed with exit code 8 at ChildProcess.whenDone (C:\\Users\\Mina\\AppData\\Roaming\\npm\\node_modules\\cordova\\node_modules\\cordova-lib\\src\\cordova\\superspawn.js:135:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:766:16) at Process.ChildProcess._handle.onexit (child_process.js:833:5) 

Here are my relevant environment variables 这是我的相关环境变量

 ANDROID_HOME=C:\\Program Files (x86)\\Android\\android-sdk ANDROID_PLATFORM_TOOLS=C:\\\\Program Files (x86)\\Android\\android-sdk\\platform-tools ANT_HOME=C:\\wamp\\apache-ant JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_25 

My Cordova build is 4.1.2. 我的Cordova版本是4.1.2。 JDK 1.8 Thank you, JDK 1.8谢谢,

1)Create the app using cordova? 1)使用cordova创建应用程序?

cordova create hello com.example.hello HelloWorld cordova创建hello com.example.hello HelloWorld

Your app name is "Hello". 您的应用名称为“Hello”。

2)Change directory to your app? 2)将目录更改为您的应用程序?

cd hello 你好

3)Add platform on your app before build your app? 3)在构建应用程序之前在应用程序上添加平台?

for Apple iOS: 对于Apple iOS:

cordova platform add ios cordova平台添加ios

for Amazon Mobile: 对于亚马逊移动:

cordova platform add amazon-fireos cordova平台添加亚马逊 - 火

for Android: 对于Android:

cordova platform add android cordova平台添加android

for Blackberry 10: 对于黑莓10:

cordova platform add blackberry10 cordova平台添加黑莓10

for Firefox OS: 对于Firefox OS:

cordova platform add firefoxos cordova平台添加firefoxos

4)Build your app? 4)构建你的应用程序?

Run the following command to build the project: 运行以下命令来构建项目:

cordova build 科尔多瓦建造

5)Test the App on an Emulator or Device? 5)在仿真器或设备上测试应用程序?

cordova emulate android cordova模仿android

Bold text are cordova commands you will run this on your CMD 粗体文本是cordova命令,您将在CMD上运行此命令

Try to delete this file: 尝试删除此文件:

%USERPROFILE%/.android/debug.keystore

or on Linux/OS X: 或者在Linux / OS X上:

~/.android/debug.keystore 

It's your debug certificate, which seems to be expired. 这是您的调试证书,似乎已过期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM