You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/09/12 20:21:59 UTC
[1/2] android commit: CB-7536 Tweak error messages for missing JDK /
SDK / AVDs
Repository: cordova-android
Updated Branches:
refs/heads/4.0.x 3cd567dc9 -> 30e8b818f
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/4.0.x
Commit: 525ce0e0ad585542d149700a442e767e3ed93c8b
Parents: 2f7ffa3
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 12 14:19:13 2014 -0400
Committer: Andrew Grieve <ag...@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 {
[2/2] android commit: Merge branch 'master' into 4.0.x (error
messages)
Posted by ag...@apache.org.
Merge branch 'master' into 4.0.x (error messages)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/30e8b818
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/30e8b818
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/30e8b818
Branch: refs/heads/4.0.x
Commit: 30e8b818f583fd6a3240b0b255ff201f008ad78a
Parents: 3cd567d 525ce0e
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 12 14:21:47 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Sep 12 14:21:47 2014 -0400
----------------------------------------------------------------------
bin/lib/check_reqs.js | 22 +++++++++++++++-------
bin/templates/cordova/lib/emulator.js | 20 ++++++++------------
2 files changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------