diff --git a/lib/devices/android/android-common.js b/lib/devices/android/android-common.js index 902700fcd..4e5b872d5 100644 --- a/lib/devices/android/android-common.js +++ b/lib/devices/android/android-common.js @@ -460,12 +460,12 @@ androidCommon.installApp = function (cb) { }; androidCommon.installRemoteWithRetry = function (remoteApk, cb) { - this.adb.installRemote(remoteApk, function (err) { - if (err) { - logger.warn("Installing remote apk failed, going to uninstall and try " + - "again"); - this.adb.uninstallApk(this.args.appPackage, function (err) { - if (err) logger.warn("Uninstalling apk failed, continuing"); + this.adb.uninstallApk(this.args.appPackage, function (err) { + if (err) logger.warn("Uninstalling apk failed, continuing"); + this.adb.installRemote(remoteApk, function (err) { + if (err) { + logger.warn("Installing remote apk failed, going to uninstall and try " + + "again"); this.removeTempApks([], function () { this.adb.push(this.args.app, remoteApk, function (err) { if (err) return cb(err); @@ -473,10 +473,10 @@ androidCommon.installRemoteWithRetry = function (remoteApk, cb) { this.adb.installRemote(remoteApk, cb); }.bind(this)); }.bind(this)); - }.bind(this)); - } else { - cb(); - } + } else { + cb(); + } + }.bind(this)); }.bind(this)); };