mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Change droidgap create to not use 'grep' and have better error messages
This commit is contained in:
parent
3fd372f9d1
commit
5164464d28
@ -49,8 +49,16 @@ class Classic
|
|||||||
# runs android create project
|
# runs android create project
|
||||||
# TODO need to allow more flexible SDK targetting via config.xml
|
# TODO need to allow more flexible SDK targetting via config.xml
|
||||||
def create_android
|
def create_android
|
||||||
target_id = `android list targets | grep id:`.split("\n").last.match(/\d+/).to_a.first
|
IO.popen("android list targets") { |f|
|
||||||
|
targets = f.readlines(nil)[0].scan(/id\:.*$/)
|
||||||
|
if (targets.length > 0)
|
||||||
|
target_id = targets.last.match(/\d+/).to_a.first
|
||||||
`android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
|
`android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
|
||||||
|
else
|
||||||
|
puts "No Android targets found. Please run 'android' and install at least one SDK package."
|
||||||
|
puts "If that makes no sense then you need to go read the Android SDK documentation."
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# copies the project/www folder into tmp/android/www
|
# copies the project/www folder into tmp/android/www
|
||||||
|
@ -29,8 +29,8 @@ class Create < Classic
|
|||||||
@content = 'index.html'
|
@content = 'index.html'
|
||||||
|
|
||||||
# stop executation on errors
|
# stop executation on errors
|
||||||
raise 'No index.html found!' unless File.exists? File.join(path, 'index.html')
|
raise 'Expected index.html in the following folder #{ path }.\nThe path is expected to be the directory droidgap create is run from or specified as a command line arg like droidgap create my_path.' unless File.exists? File.join(path, 'index.html')
|
||||||
raise 'Could not find android in your path!' if @android_sdk_path.empty?
|
raise 'Could not find android in your PATH!' if @android_sdk_path.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# reads in a config.xml file
|
# reads in a config.xml file
|
||||||
|
Loading…
Reference in New Issue
Block a user