@@ -117,8 +117,14 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
117
117
if (!platforms .exists ()) {
118
118
throw new BadSDKException (AndroidMode .getTextString ("android_sdk.error.missing_platforms_folder" , folder ));
119
119
}
120
-
121
- targetPlatform = new File (platforms , AndroidBuild .TARGET_PLATFORM );
120
+
121
+ String [] availPlatforms = platforms .list ();
122
+ int maxVersion = 26 ;
123
+ for (String availPlatform :availPlatforms ){
124
+ int platformVersion = Integer .parseInt (availPlatform .substring (availPlatform .length ()-2 ));
125
+ if (platformVersion > maxVersion ) maxVersion = platformVersion ;
126
+ }
127
+ targetPlatform = new File (platforms , "android-" +maxVersion );
122
128
if (!targetPlatform .exists ()) {
123
129
throw new BadSDKException (AndroidMode .getTextString ("android_sdk.error.missing_target_platform" ,
124
130
AndroidBuild .TARGET_SDK , platforms .getAbsolutePath ()));
@@ -133,6 +139,8 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
133
139
avdManager = findCliTool (new File (tools , "bin" ), "avdmanager" );
134
140
sdkManager = findCliTool (new File (tools , "bin" ), "sdkmanager" );
135
141
142
+ Preferences .set ("android.sdk.target" ,maxVersion +"" );
143
+
136
144
String path = Platform .getenv ("PATH" );
137
145
138
146
Platform .setenv ("ANDROID_SDK" , folder .getCanonicalPath ());
0 commit comments