diff --git a/lib/classic.rb b/lib/classic.rb index 77d31581..f28e4e72 100644 --- a/lib/classic.rb +++ b/lib/classic.rb @@ -49,8 +49,16 @@ class Classic # runs android create project # TODO need to allow more flexible SDK targetting via config.xml def create_android - target_id = `android list targets | grep id:`.split("\n").last.match(/\d+/).to_a.first - `android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }` + 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 }` + 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 # copies the project/www folder into tmp/android/www diff --git a/lib/create.rb b/lib/create.rb index 00b793c6..eec2c154 100644 --- a/lib/create.rb +++ b/lib/create.rb @@ -29,8 +29,8 @@ class Create < Classic @content = 'index.html' # stop executation on errors - raise 'No index.html found!' unless File.exists? File.join(path, 'index.html') - raise 'Could not find android in your path!' if @android_sdk_path.empty? + 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? end # reads in a config.xml file