当我尝试创建droidgap项目时,我遇到了一些麻烦。 我安装了运行droidgap项目所需的一切(jdk,ruby,git bash,...),所有这些都能很好地工作。
我发现这篇文章:phonegap android sample project not building据说我应该尝试在“bin / droidgap”文件中添加“.bat”tu“ant”命令。问题是在该文件中,“ant”命令调用不存在,因为在最后一个phonegap版本中发布了。 我收到以下错误:
C:\Users\Zakaria\Development>droidgap gen Testing
C:\Users\Zakaria\Development\Testing>droidgap create
C:\Users\Zakaria\Development\Testing>ruby C:\Users\Zakaria\Development\phonegap-android\bin\droidgap create
'/*' is not recognized as an internal or external command,
operable program or batch file.
'Licensed' is not recognized as an internal or external command,
operable program or batch file.
'contributor' is not recognized as an internal or external command,
operable program or batch file.
'this' is not recognized as an internal or external command,
operable program or batch file.
'The' is not recognized as an internal or external command,
operable program or batch file.
'grep' is not recognized as an internal or external command,
operable program or batch file.
C:/Users/Zakaria/Development/phonegap-android/lib/classic.rb:52:in `create_android': undefined method `match' for nil:NilClass (NoMethodError)
from C:/Users/Zakaria/Development/phonegap-android/lib/classic.rb:13:in `build'
from C:/Users/Zakaria/Development/phonegap-android/lib/create.rb:9:in `initialize'
from C:/Users/Zakaria/Development/phonegap-android/bin/droidgap:24:in `new'
from C:/Users/Zakaria/Development/phonegap-android/bin/droidgap:24:in `<main>'
虽然“droidgap”内容是(这里我无法取代ant bu ant.bat):
#!/usr/bin/env ruby
ROOT = File.expand_path(File.dirname(__FILE__).gsub('bin',''))
require 'fileutils'
require File.join(ROOT, "lib", "generate.rb")
require File.join(ROOT, "lib", "classic.rb")
require File.join(ROOT, "lib", "create.rb")
require File.join(ROOT, "lib", "run.rb")
require File.join(ROOT, "lib", "update.rb")
require File.join(ROOT, "lib", "test.rb")
# ---------------------------------------------------------- #
# #
# command line interface #
# #
# ---------------------------------------------------------- #
# droidgap gen [app name]
Generate.new(ARGV[1]) if ARGV.first == 'gen'
# droidgap classic (for windows users mostly)
Classic.new(ARGV[1..-1]) if ARGV.first == 'classic'
# droidgap create [path to phonegap project]
Create.new(ARGV[1]) if ARGV.first == 'create'
# droidgap run [optional directory]
Run.new if ARGV.first == 'run'
# droidgap update [params]
Update.new if ARGV.first == 'update'
# droidgap log
if ARGV.first == 'log'
$stdout.sync = true
IO.popen('adb logcat') do |f|
until f.eof?
puts f.gets
end
end
end
# droidgap test
Test.new if ARGV.first == 'test'
# TODO implement these!
puts "droidgap ship not implemented" if ARGV.first == 'ship'
if ARGV.first.nil? || ARGV.first == 'help'
help = <<-EOF
DroidGap: PhoneGap/Android Dev Script
-------------------------------------
Useful utilities for devlopers building mobile apps using PhoneGap for Android.
Usage:
droidgap <command> <parameters>
Commands:
help ...... See this message. Type help [command name] to see specific help topics.
gen ....... Generate an example PhoneGap application to current directory.
create .... Creates an Android compatible project from a www folder. Careful, this clobbers previous packaging.
classic ... Backwards support for droidgap script. Run "droidgap help classic" for more info.
run ....... Installs a valid PhoneGap Project to first device found.
log ....... Attach a logger that listens for console.log statements.
update .... Copy a fresh phonegap.jar and phonegap.js into a valid PhoneGap/Android project.
test ...... Gets edge copy of mobile-spec and runs in first device or emulator attached.
ship ...... Build and sign an APK suitable for submission to an Android Marketplace.
Quickstart:
$ droidgap gen example
$ cd example
$ droidgap create
$ cd ../example_android
$ droidgap run
Now you can launch your app and optionally start a logger with:
$ droidgap log
EOF
gen = <<-EOF
DroidGap Generate
-----------------
Generate an example PhoneGap application to path supplied or current working directory if none is supplied.
Usage:
droidgap gen [path]
EOF
run = <<-EOF
DroidGap Run
------------
Launches PhoneGap project to first device found and attaches a logger that listens for console.log statements.
Usage:
droidgap run <path>
EOF
ship = <<-EOF
DroidGap Ship
-------------
Build and sign an APK suitable for submission to an Android Marketplace.
Usage:
droidgap ship <path>
EOF
log = <<-EOF
DroidGap Log
-------------
Launches LogCat
Usage:
droidgap log
EOF
create = <<-EOF
DroidGap Create
----------------
Creates an Android compatable project from a PhoneGap project. For example, if you have MyProject with index.html this command will create MyProject-android.
Usage:
droidgap create <path>
EOF
update = <<-EOF
DroidGap Update
~~~~~~~~~~~~~~~
Builds the JS and PhoneGap Android jar file and copies them to your project.
EOF
classic = <<-EOF
DroidGap Classic
~~~~~~~~~~~~-~~~
Compatability for older droidgap scripts.
Usage:
droidgap classic [android_sdk_path] [name] [package_name] [www] [path]
android_sdk_path ... The path to your Android SDK install.
name ............... The name of your application.
package_name ....... The name of your package (For example: com.nitobi.demo)
www ................ The path to your www folder. (Wherein your HTML, CSS and JS app is.)
path ............... The path to generate the application.
EOF
puts ARGV[1].nil? ? help : eval(ARGV[1])
end
有没有人试图在Windows上运行新的phonegap版本?
谢谢,
此致
答案 0 :(得分:1)
有人建议将ant重命名为ant.bat,因为droidgap脚本是以UNIX / Mac OSX环境中的bash-script格式编写的。 Windows不使用此格式。 “ant”对Windows没有任何意义,而“ant.bat”将被解释为批处理文件并将执行。
然而,重命名脚本中的行是一个愚蠢的差事!
我建议下载gitBash。这模仿了Windows环境中的bash风格。基本上,它是另一种'cmd'程序。打开它并运行调用droidgap脚本的命令,就像执行任何其他命令一样。
我个人对PhoneGap非常不满和失望;好主意,糟糕的执行。