更新:
我按照benka和MBillau的指示进行操作,然后成功生成并构建了Android项目!!很高兴!
现在,我只能在Android模拟器上模拟项目。这是我运行emulate命令时收到的错误消息:
F:\Workplace\Cordova3.3.1>cordova emulate android
Generating config.xml from defaults for platform "android"
Preparing android project
Running on emulator for platform "android" via command "cmd" /c F:\Workplace\Cordova3.3.1\platforms\android\cordova\run --emulator
Error: An error occurred while emulating/deploying the android project.
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
at ChildProcess.<anonymous> (C:\Users\franv_000\AppData\Roaming\npm\node_modules\cordova\src\emulate.js:67: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)
在构建Android项目时,我实际上遇到了另一个错误,但是该错误消息是清晰且具有描述性的,因此我可以轻松地解决该问题。但是,此错误消息使e感到困惑,并且不知道去哪里才能找到解决方案。
您的帮助和时间将不胜感激!
首先,我想感谢PhoneGap / Cordova,它为我们提供了出色的功能。
现在,我已使用Cordova完成了在WP8平台上的开发,并为Android开发设置了环境(安装了Java,Ant,Android开发工具以及Eclipse,模拟器并创建了虚拟Android手机)
我还做的是使用CLI添加Android平台,所以我得到了一个文件夹:Platform文件夹下的Android。
当我打开该文件夹时,我期望看到的文件夹结构与wp8文件夹下的文件夹结构相似,但是完全不同。老实说,我什至不知道应该将index.html复制到哪个文件夹。而且我已经检查了Cordova / PhoneGap的文档。但一无所获。实际上,应该在该网站上放置一个关于如何将移动应用程序从A平台转换为B平台的准则(毕竟,使用PhoneGap / Cordova的主要目的是编写一次代码然后生成应用在不同的移动平台上轻松实现)
如果有人可以帮助我解决这个问题,并为我提供明确的指导方针,我将不胜感激。
先感谢您。
更新2:运行cordova仿真-d android时的错误日志
F:\Workplace\Cordova3.3.1>cordova emulate -d android
cordova library for "android" already exists. No need to download. Continuing.
Generating config.xml from defaults for platform "android"
Calling plugman.prepare for platform "android"
Preparing android project
Processing configuration changes for plugins.
Iterating over installed plugins: [ 'org.apache.cordova.contacts',
'org.apache.cordova.device',
'org.apache.cordova.device-motion',
'org.apache.cordova.device-orientation',
'org.apache.cordova.dialogs',
'org.apache.cordova.geolocation',
'org.apache.cordova.network-information',
'org.apache.cordova.splashscreen',
'org.apache.cordova.vibration' ]
Writing out cordova_plugins.js...
Ensuring plugin "org.apache.cordova.contacts" is installed correctly...
Plugin "org.apache.cordova.contacts" is good to go.
Ensuring plugin "org.apache.cordova.device" is installed correctly...
Plugin "org.apache.cordova.device" is good to go.
Ensuring plugin "org.apache.cordova.device-motion" is installed correctly...
Plugin "org.apache.cordova.device-motion" is good to go.
Ensuring plugin "org.apache.cordova.device-orientation" is installed correctly...
Plugin "org.apache.cordova.device-orientation" is good to go.
Ensuring plugin "org.apache.cordova.dialogs" is installed correctly...
Plugin "org.apache.cordova.dialogs" is good to go.
Ensuring plugin "org.apache.cordova.geolocation" is installed correctly...
Plugin "org.apache.cordova.geolocation" is good to go.
Ensuring plugin "org.apache.cordova.network-information" is installed correctly...
Plugin "org.apache.cordova.network-information" is good to go.
Ensuring plugin "org.apache.cordova.splashscreen" is installed correctly...
Plugin "org.apache.cordova.splashscreen" is good to go.
Ensuring plugin "org.apache.cordova.vibration" is installed correctly...
Plugin "org.apache.cordova.vibration" is good to go.
Wrote out Android application name to "MCBTimetable"
Wrote out Android package name to "io.cordova.MCBTimetable"
Running on emulator for platform "android" via command "cmd" /c F:\Workplace\Cordova3.3.1\platforms\android\cordova\run --emulator
exec: ant clean -f "F:\Workplace\Cordova3.3.1\platforms\android\build.xml"
[ 'ant clean -f "F:\\Workplace\\Cordova3.3.1\\platforms\\android\\build.xml"',
null,
'Buildfile: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\build.xml\r\n\r\n-check-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\n [checkenv] Inst
alled at D:\\Installation packages\\Java\\adt-bundle-windows-x86_64-20131030\\adt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-setup:\r\n [echo] Project Name
: MCBTimetable\r\n [gettype] Project Type: Application\r\n\r\n-pre-clean:\r\n\r\nclean:\r\n [delete] Deleting directory F:\\Workplace\\Cordova3.3.1\\platform
s\\android\\bin\r\n [delete] Deleting directory F:\\Workplace\\Cordova3.3.1\\platforms\\android\\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-check-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\n [chec
kenv] Installed at D:\\Installation packages\\Java\\adt-bundle-windows-x86_64-20131030\\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 F:\\Workplace\\Cordova3.3
.1\\platforms\\android\\CordovaLib\\bin\r\n [delete] Deleting directory F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\gen\r\n\r\nBUILD SUCCESSF
UL\r\nTotal time: 1 second\r\n',
'' ]
exec: ant debug -f "F:\Workplace\Cordova3.3.1\platforms\android\build.xml"
[ 'ant debug -f "F:\\Workplace\\Cordova3.3.1\\platforms\\android\\build.xml"',
null,
'Buildfile: F:\\Workplace\\Cordova3.3.1\\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] Andr
oid SDK Tools Revision 22.3.0\r\n [checkenv] Installed at D:\\Installation packages\\Java\\adt-bundle-windows-x86_64-20131030\\adt-bundle-windows-x86_64-2013103
0\\sdk\r\n\r\n-setup:\r\n [echo] Project Name: MCBTimetable\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[getbuildtools] Using latest Build Tools: 19.0.0\r\n [echo] Resolving Build Target for MCBTimetable...\r\n[gett
arget] Project Target: Android 4.4.2\r\n[gettarget] API level: 19\r\n [echo] ----------\r\n [echo] Creating output directories if needed...\r\n
[mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\
res\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\rsObj\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\
android\\bin\\rsLibs\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\gen\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\p
latforms\\android\\bin\\classes\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\dexedLibs\r\n [echo] ----------\r\n [e
cho] Resolving Dependencies for MCBTimetable...\r\n[dependency] Library dependencies:\r\n[dependency] \r\n[dependency] ------------------\r\n[dependency] Ordere
d 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-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 D:\\Installation
packages\\Java\\adt-bundle-windows-x86_64-20131030\\adt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-setup:\r\n [echo] Project Name: CordovaLib\r\n [gettype
] Project Type: Android Library\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[getbuildtools] Using latest
Build Tools: 19.0.0\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 needed...\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\C
ordovaLib\\bin\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\res\r\n [mkdir] Created dir: F:\\Workplace\\Cord
ova3.3.1\\platforms\\android\\CordovaLib\\bin\\rsObj\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\rsLibs\r\n
[mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\gen\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\andro
id\\CordovaLib\\bin\\classes\r\n [mkdir] Created dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\dexedLibs\r\n [echo] ----------\r
\n [echo] Resolving Dependencies for CordovaLib...\r\n[dependency] Library dependencies:\r\n[dependency] No Libraries\r\n[dependency] \r\n[dependency] -----
-------------\r\n\r\n-code-gen:\r\n[mergemanifest] Merging AndroidManifest files into one.\r\n[mergemanifest] Manifest merger disabled. Using project manifest o
nly.\r\n [echo] Handling aidl files...\r\n [aidl] No AIDL files to compile.\r\n [echo] ----------\r\n [echo] Handling RenderScript files...\r\n
[echo] ----------\r\n [echo] Handling Resources...\r\n [aapt] Generating resource IDs...\r\n [echo] ----------\r\n [echo] Handling BuildConf
ig class...\r\n[buildconfig] Generating BuildConfig class.\r\n\r\n-pre-compile:\r\n\r\n-compile:\r\n [javac] Compiling 73 source files to F:\\Workplace\\Cord
ova3.3.1\\platforms\\android\\CordovaLib\\bin\\classes\r\n [javac] Note: Some input files use or override a deprecated API.\r\n [javac] Note: Recompile wi
th -Xlint:deprecation for details.\r\n [echo] Creating library output jar file...\r\n [jar] Building jar: F:\\Workplace\\Cordova3.3.1\\platforms\\andro
id\\CordovaLib\\bin\\classes.jar\r\n\r\n-post-compile:\r\n\r\n-obfuscate:\r\n\r\n-dex:\r\n [echo] Library project: do not convert bytecode...\r\n\r\n-crunch
:\r\n [crunch] Crunching PNG Files in source dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\res\r\n [crunch] To destination dir: F:\\Work
place\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\res\r\n [crunch] Crunched 0 PNG files to update cache\r\n\r\n-package-resources:\r\n [echo] Libr
ary project: do not package resources...\r\n\r\n-package:\r\n [echo] Library project: do not package apk...\r\n\r\n-post-package:\r\n\r\n-do-debug:\r\n
[echo] Library project: do not create apk...\r\n[propertyfile] Creating new property file: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\bui
ld.prop\r\n[propertyfile] Updating property file: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\build.prop\r\n[propertyfile] Updating proper
ty file: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\build.prop\r\n[propertyfile] Updating property file: F:\\Workplace\\Cordova3.3.1\\pla
tforms\\android\\CordovaLib\\bin\\build.prop\r\n\r\n-post-build:\r\n\r\ndebug:\r\n\r\n-code-gen:\r\n[mergemanifest] Merging AndroidManifest files into one.\r\n[
mergemanifest] Manifest merger disabled. Using project manifest only.\r\n [echo] Handling aidl files...\r\n [aidl] No AIDL files to compile.\r\n [ec
ho] ----------\r\n [echo] Handling RenderScript files...\r\n [echo] ----------\r\n [echo] Handling Resources...\r\n [aapt] Generating resource I
Ds...\r\n [echo] ----------\r\n [echo] Handling BuildConfig class...\r\n[buildconfig] Generating BuildConfig class.\r\n\r\n-pre-compile:\r\n\r\n-compile
:\r\n [javac] Compiling 17 source files to F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\classes\r\n\r\n-post-compile:\r\n\r\n-obfuscate:\r\n\r\n-dex
:\r\n [dex] input: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\classes\r\n [dex] input: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\Cor
dovaLib\\bin\\classes.jar\r\n [dex] Pre-Dexing F:\\Workplace\\Cordova3.3.1\\platforms\\android\\CordovaLib\\bin\\classes.jar -> classes-a9bfeb13801703244de
81d2eb7af0f8a.jar\r\n [dex] Converting compiled files and external libraries into F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\classes.dex...\r\n
[dx] Merged dex A (46 defs/73.9KiB) with dex B (174 defs/271.6KiB). Result is 220 defs/420.7KiB. Took 0.2s\r\n\r\n-crunch:\r\n [crunch] Crunching PNG Fi
les in source dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\res\r\n [crunch] To destination dir: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\
\res\r\n [crunch] Processing image to cache: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\res\\drawable-hdpi\\icon.png => F:\\Workplace\\Cordova3.3.1\\pla
tforms\\android\\bin\\res\\drawable-hdpi\\icon.png\r\n [crunch] (processed image to cache entry F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\d
rawable-hdpi\\icon.png: 67% size of source)\r\n [crunch] Processing image to cache: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\res\\drawable-ldpi\\icon.
png => F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\drawable-ldpi\\icon.png\r\n [crunch] (processed image to cache entry F:\\Workplace\\Cordov
a3.3.1\\platforms\\android\\bin\\res\\drawable-ldpi\\icon.png: 0% size of source)\r\n [crunch] Processing image to cache: F:\\Workplace\\Cordova3.3.1\\platfor
ms\\android\\res\\drawable-mdpi\\icon.png => F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\drawable-mdpi\\icon.png\r\n [crunch] (processed imag
e to cache entry F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\drawable-mdpi\\icon.png: 0% size of source)\r\n [crunch] Processing image to cache
: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\res\\drawable-xhdpi\\icon.png => F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\drawable-xhdpi\\i
con.png\r\n [crunch] (processed image to cache entry F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\drawable-xhdpi\\icon.png: 53% size of source
)\r\n [crunch] Processing image to cache: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\res\\drawable\\icon.png => F:\\Workplace\\Cordova3.3.1\\platforms\\
android\\bin\\res\\drawable\\icon.png\r\n [crunch] (processed image to cache entry F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\res\\drawable\\icon
.png: 53% size of source)\r\n [crunch] Crunched 5 PNG files to update cache\r\n\r\n-package-resources:\r\n [aapt] Creating full resource package...\r\n
[aapt] Warning: AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest.\r\n\r\n-pack
age:\r\n[apkbuilder] Current build type is different than previous build: forced apkbuilder run.\r\n[apkbuilder] Creating MCBTimetable-debug-unaligned.apk and s
igning it with a debug key...\r\n\r\n-post-package:\r\n\r\n-do-debug:\r\n [zipalign] Running zip align on final apk...\r\n [echo] Debug Package: F:\\Workpla
ce\\Cordova3.3.1\\platforms\\android\\bin\\MCBTimetable-debug.apk\r\n[propertyfile] Creating new property file: F:\\Workplace\\Cordova3.3.1\\platforms\\android\
\bin\\build.prop\r\n[propertyfile] Updating property file: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\build.prop\r\n[propertyfile] Updating property
file: F:\\Workplace\\Cordova3.3.1\\platforms\\android\\bin\\build.prop\r\n[propertyfile] Updating property file: F:\\Workplace\\Cordova3.3.1\\platforms\\android
\\bin\\build.prop\r\n\r\n-post-build:\r\n\r\ndebug:\r\n\r\nBUILD SUCCESSFUL\r\nTotal time: 15 seconds\r\n',
'' ]
exec: adb devices
[ 'adb devices', null, 'List of devices attached \r\n\r\n', '' ]
exec: adb devices
[ 'adb devices', null, 'List of devices attached \r\n\r\n', '' ]
exec: android list avds
[ 'android list avds',
null,
'Available Android Virtual Devices:\n Name: MyVA\n Path: C:\\Users\\franv_000\\.android\\avd\\MyVA.avd\n Target: Android 4.4.2 (API level 19)\n ABI
: armeabi-v7a\n Skin: 768x1280\n',
'' ]
exec: android list avds
[ 'android list avds',
null,
'Available Android Virtual Devices:\n Name: MyVA\n Path: C:\\Users\\franv_000\\.android\\avd\\MyVA.avd\n Target: Android 4.4.2 (API level 19)\n ABI
: armeabi-v7a\n Skin: 768x1280\n',
'' ]
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
child_process.spawn(cmd,[/c, F:\Workplace\Cordova3.3.1\platforms\android\cordova\run, --emulator]) = 8
Error: An error occurred while emulating/deploying the android project.
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
at ChildProcess.<anonymous> (C:\Users\franv_000\AppData\Roaming\npm\node_modules\cordova\src\emulate.js:67: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)
添加android platform
直通CLI时,它应该创建所有必需的文件夹,并从主www
文件夹复制共享代码(假设您的共享代码位于主www
文件夹中,而不是platform/wp8
)中。
您的index.html应该进入该/www
文件夹。然后,platform/android/assets/www
当您添加Android
平台或使用CLI工具构建应用程序时,它将被复制到文件夹中。(感谢@MBillau,因为您的输入应该更清楚。)
如果您已经为WP8应用程序实现了任何本机代码,则可能还必须为Android应用程序实现它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句