Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A319111CB for ; Wed, 10 Sep 2014 14:15:58 +0000 (UTC) Received: (qmail 77297 invoked by uid 500); 10 Sep 2014 14:15:58 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 77278 invoked by uid 500); 10 Sep 2014 14:15:58 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 77269 invoked by uid 99); 10 Sep 2014 14:15:58 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Sep 2014 14:15:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1B6341E606; Wed, 10 Sep 2014 14:15:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Message-Id: <4032167dd0f6489c87b3270cff46fa4d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: android commit: CB-7511 Auto-detect Android SDK when Android Studio is installed Date: Wed, 10 Sep 2014 14:15:58 +0000 (UTC) Repository: cordova-android Updated Branches: refs/heads/master 835465105 -> 8237c4114 CB-7511 Auto-detect Android SDK when Android Studio is installed Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/8237c411 Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/8237c411 Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/8237c411 Branch: refs/heads/master Commit: 8237c41143abf594ff0bcc717a7847a7aa38654c Parents: 8354651 Author: Andrew Grieve Authored: Wed Sep 10 10:14:38 2014 -0400 Committer: Andrew Grieve Committed: Wed Sep 10 10:14:38 2014 -0400 ---------------------------------------------------------------------- bin/lib/check_reqs.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/8237c411/bin/lib/check_reqs.js ---------------------------------------------------------------------- diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js index 40f3ade..d2b3dcf 100644 --- a/bin/lib/check_reqs.js +++ b/bin/lib/check_reqs.js @@ -141,6 +141,20 @@ module.exports.check_android = function() { var androidCmdPath = forgivingWhichSync('android'); var adbInPath = !!forgivingWhichSync('adb'); var hasAndroidHome = !!process.env['ANDROID_HOME'] && fs.existsSync(process.env['ANDROID_HOME']); + function maybeSetAndroidHome(value) { + if (fs.existsSync(value)) { + hasAndroidHome = true; + process.env['ANDROID_HOME'] = value; + } + } + if (!hasAndroidHome && !androidCmdPath) { + if (isWindows) { + maybeSetAndroidHome(path.join(process.env['LOCALAPPDATA'], 'Android', 'android-studio', 'sdk')); + maybeSetAndroidHome(path.join(process.env['ProgramFiles'], 'Android', 'android-studio', 'sdk')); + } else if (process.platform == 'darwin') { + maybeSetAndroidHome('/Applications/Android Studio.app/sdk'); + } + } if (hasAndroidHome && !androidCmdPath) { process.env['PATH'] += path.delimiter + path.join(process.env['ANDROID_HOME'], 'tools'); } @@ -171,7 +185,8 @@ module.exports.check_android_target = function(valid_target) { .then(function(output) { if (!output.match(valid_target)) { throw new Error('Please install Android target "' + valid_target + '".\n' + - 'Hint: Run "android" from your command-line to open the SDK manager.'); + output + '\n\n' + + 'Hint: Install it using the SDK manager by running: ' + forgivingWhichSync('android')); } }); };