I have some troubles when I try to create a droidgap project. I installed everything required to run a droidgap project (jdk, ruby, git bash, ...) and all of them work perfectly.
I found this post : phonegap android sample project not building where it's said that I should try to add ".bat" tu the "ant" command found in the "bin/droidgap" file. The problem is that in that file the "ant" command call doesnt't exist since in the last phonegap version was released. I get the following errors:
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>'
While the "droidgap" content is (here is where i can't replace 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" f开发者_如何学JAVAor 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
Did anyone tried to run the new phonegap version on windows?
Thank you,
Regards
Someone suggested renaming ant to ant.bat because the droidgap script is written in the bash-script format found on UNIX/Mac OSX environments. Windows does not use this format. "ant" will mean nothing to Windows, whereas, "ant.bat" will be interpreted as a batch file and will execute.
However, renaming the lines in the script is a fool's errand!
I suggest downloading gitBash. This mimics the bash-style on a Windows environment. Basically, it's an alternative 'cmd' program. Open it and run the command that calls the droidgap script as you would any other command.
I personally am extremely underwhelmed and disappointed by PhoneGap; great idea, awful execution.
精彩评论