cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: CB-7536 Tweak error messages for missing JDK / SDK / AVDs
Date Fri, 12 Sep 2014 18:21:39 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/master 2f7ffa363 -> 525ce0e0a


CB-7536 Tweak error messages for missing JDK / SDK / AVDs


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/525ce0e0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/525ce0e0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/525ce0e0

Branch: refs/heads/master
Commit: 525ce0e0ad585542d149700a442e767e3ed93c8b
Parents: 2f7ffa3
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri Sep 12 14:19:13 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Sep 12 14:19:13 2014 -0400

----------------------------------------------------------------------
 bin/lib/check_reqs.js                 | 22 +++++++++++++++-------
 bin/templates/cordova/lib/emulator.js | 20 ++++++++------------
 2 files changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/525ce0e0/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index edfa273..4fa8b1d 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -126,13 +126,15 @@ module.exports.check_java = function() {
         }
     }).then(function() {
         var msg =
-            'Failed to run "java -version", make sure your java environment is set up\n'
+
-            'including JDK and JRE.\n' +
-            'Your JAVA_HOME variable is: ' + process.env['JAVA_HOME'];
+            'Failed to run "java -version", make sure that you have a JDK installed.\n' +
+            'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n';
+        if (process.env['JAVA_HOME']) {
+            msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n';
+        }
         return tryCommand('java -version', msg)
-    }).then(function() {
-        msg = 'Failed to run "javac -version", make sure you have a Java JDK (not just a
JRE) installed.';
-        return tryCommand('javac -version', msg)
+        .then(function() {
+            return tryCommand('javac -version', msg);
+        });
     });
 }
 
@@ -192,6 +194,10 @@ module.exports.check_android = function() {
     });
 };
 
+module.exports.getAbsoluteAndroidCmd = function() {
+    return forgivingWhichSync('android').replace(/([ \\])/g, '\\$1');
+};
+
 module.exports.check_android_target = function(valid_target) {
     // valid_target can look like:
     //   android-19
@@ -202,8 +208,10 @@ module.exports.check_android_target = function(valid_target) {
     return tryCommand('android list targets --compact', msg)
     .then(function(output) {
         if (output.split('\n').indexOf(valid_target) == -1) {
+            var androidCmd = module.exports.getAbsoluteAndroidCmd();
             throw new Error('Please install Android target: "' + valid_target + '".\n' +
-                'Hint: Open the SDK manager by running: ' + forgivingWhichSync('android'));
+                'Hint: Open the SDK manager by running: ' + androidCmd + '\n' +
+                'Or install directly via: ' + androidCmd + ' update sdk --no-ui --all --filter
"' + valid_target + '"');
         }
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/525ce0e0/bin/templates/cordova/lib/emulator.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/emulator.js b/bin/templates/cordova/lib/emulator.js
index 69f0e1b..4c3d451 100644
--- a/bin/templates/cordova/lib/emulator.js
+++ b/bin/templates/cordova/lib/emulator.js
@@ -28,6 +28,7 @@ var shell = require('shelljs'),
     ROOT  = path.join(__dirname, '..', '..'),
     child_process = require('child_process'),
     new_emulator = 'cordova_emulator';
+var check_reqs = require('./check_reqs');
 
 /**
  * Returns a Promise for a list of emulator images in the form of objects
@@ -84,7 +85,7 @@ module.exports.list_images = function() {
  * Returns a promise.
  */
 module.exports.best_image = function() {
-    var project_target = this.get_target().replace('android-', '');
+    var project_target = check_reqs.get_target().replace('android-', '');
     return this.list_images()
     .then(function(images) {
         var closest = 9999;
@@ -120,11 +121,6 @@ module.exports.list_started = function() {
     });
 }
 
-module.exports.get_target = function() {
-    var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties'));
-    return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
-}
-
 // Returns a promise.
 module.exports.list_targets = function() {
     return exec('android list targets')
@@ -156,7 +152,7 @@ module.exports.start = function(emulator_ID) {
     .then(function(list) {
         started_emulators = list;
         num_started = started_emulators.length;
-        if (typeof emulator_ID === 'undefined') {
+        if (!emulator_ID) {
             return self.list_images()
             .then(function(emulator_list) {
                 if (emulator_list.length > 0) {
@@ -167,11 +163,11 @@ module.exports.start = function(emulator_ID) {
                         return emulator_ID;
                     });
                 } else {
-                    return Q.reject('ERROR : No emulator images (avds) found, if you would
like to create an\n' +
-                        ' avd follow the instructions provided here:\n' +
-                        ' http://developer.android.com/tools/devices/index.html\n' +
-                        ' Or run \'android create avd --name <name> --target <targetID>\'\n'
+
-                        ' in on the command line.');
+                    var androidCmd = check_reqs.getAbsoluteAndroidCmd();
+                    return Q.reject('ERROR : No emulator images (avds) found.\n' +
+                        '1. Download desired System Image by running: ' + androidCmd + '
sdk\n' +
+                        '2. Create an AVD by running: ' + androidCmd + ' avd\n'
+                        'HINT: For a faster emulator, use an Intel System Image and install
the HAXM device driver\n');
                 }
             });
         } else {


Mime
View raw message