@@ -7,7 +7,7 @@ import * as semver from "semver";
7
7
export class AndroidToolsInfo implements IAndroidToolsInfo {
8
8
private static ANDROID_TARGET_PREFIX = "android" ;
9
9
private static SUPPORTED_TARGETS = [ "android-17" , "android-18" , "android-19" , "android-21" , "android-22" , "android-23" ] ;
10
- private static MIN_REQUIRED_COMPILE_TARGET = 21 ;
10
+ private static MIN_REQUIRED_COMPILE_TARGET = 22 ;
11
11
private static REQUIRED_BUILD_TOOLS_RANGE_PREFIX = ">=22" ;
12
12
private static VERSION_REGEX = / ^ ( \d + \. ) { 2 } \d + $ / ;
13
13
private showWarningsAsErrors : boolean ;
@@ -120,12 +120,23 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
120
120
private getCompileSdk ( ) : IFuture < number > {
121
121
return ( ( ) : number => {
122
122
if ( ! this . selectedCompileSdk ) {
123
- let latestValidAndroidTarget = this . getLatestValidAndroidTarget ( ) . wait ( ) ;
124
- if ( latestValidAndroidTarget ) {
125
- let integerVersion = this . parseAndroidSdkString ( latestValidAndroidTarget ) ;
123
+ let userSpecifiedCompileSdk = this . $options . compileSdk ;
124
+ if ( userSpecifiedCompileSdk ) {
125
+ let installedTargets = this . getInstalledTargets ( ) . wait ( ) ;
126
+ let androidCompileSdk = `${ AndroidToolsInfo . ANDROID_TARGET_PREFIX } -${ userSpecifiedCompileSdk } ` ;
127
+ if ( ! _ . contains ( installedTargets , androidCompileSdk ) ) {
128
+ this . $errors . failWithoutHelp ( `You have specified '${ userSpecifiedCompileSdk } ' for compile sdk, but it is not installed on your system.` ) ;
129
+ }
130
+
131
+ this . selectedCompileSdk = userSpecifiedCompileSdk ;
132
+ } else {
133
+ let latestValidAndroidTarget = this . getLatestValidAndroidTarget ( ) . wait ( ) ;
134
+ if ( latestValidAndroidTarget ) {
135
+ let integerVersion = this . parseAndroidSdkString ( latestValidAndroidTarget ) ;
126
136
127
- if ( integerVersion && integerVersion >= AndroidToolsInfo . MIN_REQUIRED_COMPILE_TARGET ) {
128
- this . selectedCompileSdk = integerVersion ;
137
+ if ( integerVersion && integerVersion >= AndroidToolsInfo . MIN_REQUIRED_COMPILE_TARGET ) {
138
+ this . selectedCompileSdk = integerVersion ;
139
+ }
129
140
}
130
141
}
131
142
}
0 commit comments