update installAndroidApp to first uninstall app (fix #424)

This commit is contained in:
Jonathan Lipps
2013-04-10 16:35:25 -07:00
parent 4d0fcd1648
commit 7045a05f41
+14 -5
View File
@@ -336,15 +336,24 @@ module.exports.buildAndroidApp = function(grunt, appName, cb) {
};
module.exports.installAndroidApp = function(grunt, appName, cb) {
var pkgMap = {'ApiDemos': 'com.example.android.apis'};
if (!_.has(pkgMap, appName)) {
var msg = "We don't know about appName " + appName + ", please edit " +
"grunt-helpers.js:installAndroidApp() to add it and its " +
"package identifier";
grunt.fatal(new Error(msg));
}
var appPath = path.resolve(__dirname, "sample-code/apps/" + appName,
"bin/" + appName + "-debug.apk");
exec("adb install -r " + appPath, function(err, stdout) {
if (err) {
grunt.fatal(err);
} else {
exec("adb uninstall " + pkgMap[appName], function(err, stdout) {
if (err) return grunt.fatal(err);
grunt.log.write(stdout);
exec("adb install -r " + appPath, function(err, stdout) {
if (err) return grunt.fatal(err);
grunt.log.write(stdout);
cb();
}
});
});
};