Skip to content

Commit a95a447

Browse files
Merge pull request #6 from DeerajTheepshi/GSoC19-p1.1
[FIX] Locate SDK-Check for any platform > 26
2 parents 6d8aa4d + 50d213b commit a95a447

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

mode/languages/mode.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ android_mode.dialog.cannot_export_package_body = The sketch still has the defaul
8888
android_mode.dialog.cannot_use_default_icons_title = Cannot export package...
8989
android_mode.dialog.cannot_use_default_icons_body = The sketch does not include all required app icons. Processing could use its default set of Android icons, which are okay to test the app on your device, but a bad idea to distribute it on the Play store. Create a full set of unique icons for your app, and copy them into the sketch folder. Once you have done that, try exporting the sketch again.<br><br>For more info on distributing apps from Processing,<br>check <a href=\"%s\">this online tutorial</a>.
9090
android_mode.warn.cannot_load_sdk_title = Bad news...
91-
android_mode.warn.cannot_load_sdk_body = The Android SDK could not be loaded.\nThe Android Mode will be disabled.
91+
android_mode.warn.cannot_load_sdk_body = The Android SDK could not be loaded, because:\n%s.\nThe Android Mode will be disabled.
9292
android_mode.info.cannot_open_sdk_path = "Android SDK path couldn't be opened.";
9393
android_mode.error.cannot_create_avd = "Could not create a virtual device for the emulator.";
9494
android_mode.dialog.no_devices_found_title = No devices found!
@@ -139,9 +139,9 @@ android_sdk.dialog.found_installed_sdk_body = Processing found a valid Android S
139139
android_sdk.option.use_existing_sdk = Use existing SDK
140140
android_sdk.option.download_new_sdk = Download new SDK
141141
android_sdk.dialog.cannot_find_sdk_title = Cannot find an Android SDK...
142-
android_sdk.dialog.cannot_find_sdk_body = Processing did not find an Android SDK on this computer. If there is one, and you know where it is, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API %s.
142+
android_sdk.dialog.cannot_find_sdk_body = Processing did not find an Android SDK on this computer. If there is one, and you know where it is, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API 26 or higher.
143143
android_sdk.dialog.invalid_sdk_title = Android SDK is not valid...
144-
android_sdk.dialog.invalid_sdk_body = Processing found an Android SDK, but is not valid. It could be missing some files, or might not be including the required platform for API %s.<br><br>If a valid SDK is available in a different location, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API %s.
144+
android_sdk.dialog.invalid_sdk_body = Processing found an Android SDK, but is not valid. It could be missing some files, or might not be including the required platform for API 26 or higher.<br><br>If a valid SDK is available in a different location, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API 26 or higher.
145145
android_sdk.option.download_sdk = Download SDK automatically
146146
android_sdk.option.locate_sdk = Locate SDK path manually
147147
android_sdk.dialog.download_phone_image_title = Download phone system image?
@@ -172,7 +172,7 @@ android_sdk.error.missing_tools_folder = There is no tools folder in %s
172172
android_sdk.error.missing_platform_tools_folder = There is no platform-tools folder in %s
173173
android_sdk.error.missing_build_tools_folder = There is no build-tools folder in %s
174174
android_sdk.error.missing_platforms_folder = There is no platforms folder in %s
175-
android_sdk.error.missing_target_platform = There is no Android %s in %s
175+
android_sdk.error.missing_target_platform = There is no Android %s (or greater) in %s
176176
android_sdk.error.missing_android_jar = android.jar for plaform %s is missing from %s
177177
android_debugger.info.removing_expired_keystore = Removing expired debug.keystore file.
178178
android_debugger.error.cannot_remove_expired_keystore = Could not remove the expired debug.keystore file.

mode/src/processing/mode/android/AndroidSDK.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,17 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
119119
if (!platforms.exists()) {
120120
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_platforms_folder", folder));
121121
}
122-
123-
targetPlatform = new File(platforms, AndroidBuild.TARGET_PLATFORM);
122+
123+
String[] availPlatforms = platforms.list();
124+
int maxVersion = 26;
125+
for (String availPlatform:availPlatforms){
126+
int platformVersion = Integer.parseInt(availPlatform.substring(availPlatform.length()-2));
127+
if (platformVersion >= maxVersion) maxVersion = platformVersion;
128+
}
129+
targetPlatform = new File(platforms, "android-"+maxVersion);
124130
if (!targetPlatform.exists()) {
125131
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_target_platform",
126-
AndroidBuild.TARGET_SDK, platforms.getAbsolutePath()));
132+
maxVersion, platforms.getAbsolutePath()));
127133
}
128134

129135
androidJar = new File(targetPlatform, "android.jar");
@@ -135,6 +141,8 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
135141
avdManager = findCliTool(new File(tools, "bin"), "avdmanager");
136142
sdkManager = findCliTool(new File(tools, "bin"), "sdkmanager");
137143

144+
Preferences.set("android.sdk.target",maxVersion+"");
145+
138146
String path = Platform.getenv("PATH");
139147

140148
Platform.setenv("ANDROID_SDK", folder.getCanonicalPath());

0 commit comments

Comments
 (0)