Make sure manifest compilation works with API 17.

This commit is contained in:
Payman Delshad
2013-08-28 15:29:50 +02:00
parent 2f121fea9a
commit 8728e05127
2 changed files with 23 additions and 16 deletions

View File

@@ -209,29 +209,17 @@ ADB.prototype.insertSelendroidManifest = function(serverPath, cb) {
ADB.prototype.compileManifest = function(manifest, manifestPackage, targetPackage, cb) {
logger.info("Compiling manifest " + manifest);
var androidHome = process.env.ANDROID_HOME;
if (typeof androidHome !== "string") {
return cb(new Error("ANDROID_HOME was not exported!"));
}
var platforms = path.resolve(androidHome , 'platforms')
, platform = 'android-18';
// android-18 may be called android-4.3
if (!fs.existsSync(path.resolve(platforms, platform))) {
platform = 'android-4.3';
if (!fs.existsSync(path.resolve(platforms, platform))) {
return cb(new Error("Platform doesn't exist " + platform));
}
var platform = helpers.getAndroidPlatform();
if (!platform || !platform[1]) {
return cb(new Error("Required platform doesn't exist (API level >= 17)"));
}
// Compile manifest into manifest.xml.apk
var compileManifest = [this.binaries.aapt + ' package -M "', manifest + '"',
' --rename-manifest-package "', manifestPackage + '"',
' --rename-instrumentation-target-package "', targetPackage + '"',
' -I "', path.resolve(platforms, platform, 'android.jar') +'" -F "',
' -I "', path.resolve(platform[1], 'android.jar') +'" -F "',
manifest, '.apk" -f'].join('');
logger.debug(compileManifest);
exec(compileManifest, { maxBuffer: 524288 }, function(err, stdout, stderr) {

View File

@@ -332,3 +332,22 @@ exports.getGitRev = function(cb) {
cb(null, stdout.trim());
});
};
exports.getAndroidPlatform = function(cb) {
var androidHome = process.env.ANDROID_HOME;
if (typeof androidHome !== "string") {
logger.error("ANDROID_HOME was not exported!");
return null;
}
var locs = ['android-4.2', 'android-17', 'android-4.3', 'android-18'];
var res = null;
_.each(locs, function(loc) {
var platforms = path.resolve(androidHome , 'platforms')
, platform = loc;
if (fs.existsSync(path.resolve(platforms, platform))) {
res = [platform, path.resolve(platforms, platform)];
}
});
return res;
};