【问题标题】:Can't run the new PhoneGap version on Windows 7无法在 Windows 7 上运行新的 PhoneGap 版本
【发布时间】:2010-09-08 10:20:30
【问题描述】:

我在尝试创建 droidgap 项目时遇到了一些麻烦。 我安装了运行 droidgap 项目所需的所有东西(jdk、ruby、git bash、...),它们都运行良好。

我发现了这篇文章:phonegap android sample project not building,据说我应该尝试在“bin/droidgap”文件中找到“ant”命令添加“.bat”。问题是,在该文件中,自上一个 phonegap 版本发布以来,不存在“ant”命令调用。 我收到以下错误:

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 版本吗?

谢谢,

问候

【问题讨论】:

    标签: android configuration cordova


    【解决方案1】:

    有人建议将 ant 重命名为 ant.bat,因为 droidgap 脚本是用 UNIX/Mac OSX 环境中的 bash 脚本格式编写的。 Windows 不使用这种格式。 "ant" 对 Windows 没有任何意义,而 "ant.bat" 将被解释为批处理文件并执行。

    但是,重命名脚本中的行是徒劳的!

    我建议下载 gitBash。这模仿了 Windows 环境中的 bash 风格。基本上,它是一个替代的“cmd”程序。打开它并像运行任何其他命令一样运行调用 droidgap 脚本的命令。

    我个人对 PhoneGap 感到非常失望和失望;好主意,糟糕的执行。

    【讨论】:

    • 完全同意你的看法。 PhoneGap 是个好主意,但它们让我们构建/创建 Android 模板项目以导入 Eclipse 的方式很糟糕。我花了一个多星期才获得 Google 的社区支持。但直到现在我在构建时仍然出错:(
    猜你喜欢
    • 1970-01-01
    • 2012-08-28
    • 2011-12-01
    • 2011-02-06
    • 2015-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-26
    相关资源
    最近更新 更多