@@ -6,6 +6,7 @@ import constants = require("../constants");
66import helpers = require( "../common/helpers" ) ;
77import usbLivesyncServiceBaseLib = require( "../common/services/usb-livesync-service-base" ) ;
88import path = require( "path" ) ;
9+ import semver = require( "semver" ) ;
910
1011export class UsbLiveSyncService extends usbLivesyncServiceBaseLib . UsbLiveSyncServiceBase implements IUsbLiveSyncService {
1112 private excludedProjectDirsAndFiles = [
@@ -27,16 +28,33 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
2728 $dispatcher : IFutureDispatcher ,
2829 $childProcess : IChildProcess ,
2930 $iOSEmulatorServices : Mobile . IiOSSimulatorService ,
30- private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ) {
31+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
32+ private $projectDataService : IProjectDataService ,
33+ private $prompter : IPrompter ) {
3134 super ( $devicesServices , $mobileHelper , $localToDevicePathDataFactory , $logger , $options , $deviceAppDataFactory , $fs , $dispatcher , $childProcess , $iOSEmulatorServices ) ;
3235 }
3336
3437 public liveSync ( platform : string ) : IFuture < void > {
3538 return ( ( ) => {
3639 platform = platform || this . initialize ( platform ) . wait ( ) ;
40+ let platformLowerCase = platform . toLowerCase ( ) ;
41+ let platformData = this . $platformsData . getPlatformData ( platformLowerCase ) ;
42+
43+ if ( platformLowerCase === this . $devicePlatformsConstants . Android . toLowerCase ( ) ) {
44+ this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
45+ let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
46+ if ( semver . lt ( frameworkVersion , "1.2.2" ) ) {
47+ let shouldUpdate = this . $prompter . confirm ( "You need Android Runtime 1.2.2 or later for LiveSync to work properly. Do you want to update your runtime now?" ) . wait ( ) ;
48+ if ( shouldUpdate ) {
49+ this . $platformService . updatePlatforms ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) . wait ( ) ;
50+ } else {
51+ return ;
52+ }
53+ }
54+ }
55+
3756 this . $platformService . preparePlatform ( platform ) . wait ( ) ;
3857
39- let platformData = this . $platformsData . getPlatformData ( platform . toLowerCase ( ) ) ;
4058 let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
4159
4260 let restartAppOnDeviceAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData , localToDevicePaths ?: Mobile . ILocalToDevicePathData [ ] ) : IFuture < void > => {
0 commit comments