I was trying to re-build a project that so far worked but this time I've got this error:
ERROR running one or more of the platforms: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project
After a few good hours of drilling down I found the root of the problem in platforms/android/cordova/lib/check_reqs.js
First off, check_android_target failed silently:
module.exports.check_android_target = function(valid_target) {
// valid_target can look like:
// android-19
// android-L
// Google Inc.:Google APIs:20
// Google Inc.:Glass Development Kit Preview:20
if (!valid_target) valid_target = module.exports.get_target();
var msg = 'Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.';
return tryCommand('android list targets --compact', msg)
.then(function(output) {
var targets = output.split('\n');
if (targets.indexOf(valid_target) >= 0) {
return targets;
}
var androidCmd = module.exports.getAbsoluteAndroidCmd();
throw new CordovaError('Please install Android target: "' + valid_target + '".\n\n' +
'Hint: Open the SDK manager by running: ' + androidCmd + '\n' +
'You will require:\n' +
'1. "SDK Platform" for ' + valid_target + '\n' +
'2. "Android SDK Platform-tools (latest)\n' +
'3. "Android SDK Build-tools" (latest)');
});
};
those handy messages never got printed to console and module.exports.get_target() returned android-23 which (among other targets) I had installed.
To simply compile I hardcoded return true which is very messy but I'm sure there's a more elegant way of handling this.
Secondly, check_gradle failed because a newer android sdk no longer has templates/gradle/wrapper in the sdk/tools folder. I sym-linked from an older sdk to the current sdk for now. Messy again, but it did the trick. I would be great for this path to be updated or a download/helpful message to be displayed
I was trying to re-build a project that so far worked but this time I've got this error:
After a few good hours of drilling down I found the root of the problem in
platforms/android/cordova/lib/check_reqs.js
First off,
check_android_target
failed silently:those handy messages never got printed to console and
module.exports.get_target()
returnedandroid-23
which (among other targets) I had installed.To simply compile I hardcoded
return true
which is very messy but I'm sure there's a more elegant way of handling this.Secondly,
check_gradle
failed because a newer android sdk no longer hastemplates/gradle/wrapper
in thesdk/tools
folder. I sym-linked from an older sdk to the current sdk for now. Messy again, but it did the trick. I would be great for this path to be updated or a download/helpful message to be displayedThis was done using
cca 0.8.1
HTH, George