public boolean uploadAndInstallApk(@NotNull IDevice device,@NotNull String packageName,@NotNull File localFile,@NotNull LaunchStatus launchStatus){
  if (!needsInstall(device,localFile,packageName)) {
    return true;
  }
  String remotePath="/data/local/tmp/" + packageName;
  myPrinter.stdout("$ adb push " + localFile + " "+ remotePath);
  try {
    device.pushFile(localFile.getPath(),remotePath);
    boolean installed=installApp(device,remotePath,packageName,launchStatus);
    if (installed) {
      myInstalledApkCache.setInstalled(device,localFile,packageName);
    }
    return installed;
  }
 catch (  Exception e) {
    myPrinter.stderr(e.toString());
    return false;
  }
}

public boolean uploadAndInstallApk ( @ NotNull IDevice device , @ NotNull String packageName , @ NotNull File localFile , @ NotNull LaunchStatus launchStatus ) { if ( ! needsInstall ( device , localFile , packageName ) ) { return true ; } String remotePath = "/data/local/tmp/" + packageName ; myPrinter . stdout ( "$ adb push " + localFile + " " + remotePath ) ; try { device . pushFile ( localFile . getPath ( ) , remotePath ) ; boolean installed = installApp ( device , remotePath , packageName , launchStatus ) ; if ( installed ) { myInstalledApkCache . setInstalled ( device , localFile , packageName ) ; } return installed ; } catch ( Exception e ) { myPrinter . stderr ( e . toString ( ) ) ; return false ; } }
installs the given apk on the device .
