Skip to content

Commit 0c6b2e1

Browse files
authored
Merge pull request #709 from rupeshkumar22/emulator_improvements
Final Emulator Improvements for Apple M1 Silicon and cmdline-tools check
2 parents ad0cf61 + 03345a3 commit 0c6b2e1

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

mode/languages/mode.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ android_sdk.dialog.accept_sdk_license_body = You need to accept the terms of the
188188
android_sdk.warn.cannot_run_adb_title = Trouble with adb!
189189
android_sdk.warn.cannot_run_adb_body = Could not run the adb tool from the Android SDK.\nOne possibility is that its executable permission\nis not properly set. You can try setting this\npermission manually, or re-installing the SDK.\n\nThe mode will be disabled until this problem is fixed.\n
190190
android_sdk.error.missing_sdk_folder = %s does not exist
191-
android_sdk.error.missing_tools_folder = There is no tools folder in %s
191+
android_sdk.error.missing_cmdtools_folder_found_sdktools = There is no cmdline-tools/latest folder in %s and SDK Tools(sdk/tools) got deprecated.\nInstall cmdline-tools in the existing SDK specifically or Create New SDK.
192+
android_sdk.error.missing_cmdtools_folder = There is no `cmdline-tools/latest` folder in %s \nInstall cmdline-tools in the existing SDK specifically or Create New SDK.
192193
android_sdk.error.missing_platform_tools_folder = There is no platform-tools folder in %s
193194
android_sdk.error.missing_build_tools_folder = There is no build-tools folder in %s
194195
android_sdk.error.missing_platforms_folder = There is no platforms folder in %s

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,19 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
102102
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_sdk_folder", folder));
103103
}
104104

105-
File tmp = new File(folder, "cmdline-tools/latest");
106-
if (!tmp.exists()) {
107-
tmp = new File(folder, "tools");
108-
} else if (!tmp.exists()) {
109-
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_tools_folder", folder));
110-
}
111-
cmdlineTools = tmp;
105+
File cmdlineTools = new File(folder, "cmdline-tools/latest");
106+
// we need only command line tools, as sdk/tools got deprecated and can't be used with java 17
107+
if (!cmdlineTools.exists) {
108+
// lets be more specific to show the error
109+
File sdkTools = new File(folder, "tools");
110+
if (sdkTools.exists) {
111+
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_cmdtools_folder_found_sdktools", folder));
112+
} else {
113+
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_cmdtools_folder", folder));
114+
}
115+
}
116+
// if we reached here, that means command line tools exists
117+
// ok to go with the command line tools
112118

113119
platformTools = new File(folder, "platform-tools");
114120
if (!platformTools.exists()) {
@@ -874,4 +880,4 @@ public CancelException(final String message) {
874880
super(message);
875881
}
876882
}
877-
}
883+
}

mode/src/processing/mode/android/SysImageDownloader.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
/*
44
Part of the Processing project - http://processing.org
5-
5+
66
Copyright (c) 2016-21 The Processing Foundation
77
88
This program is free software; you can redistribute it and/or modify
99
it under the terms of the GNU General Public License version 2
1010
as published by the Free Software Foundation.
11-
11+
1212
This program is distributed in the hope that it will be useful,
1313
but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
GNU General Public License for more details.
16-
16+
1717
You should have received a copy of the GNU General Public License
1818
along with this program; if not, write to the Free Software Foundation,
1919
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -253,12 +253,16 @@ private void getDownloadUrls(UrlHolder urlHolder,
253253
XPathExpression expr;
254254
NodeList remotePackages;
255255

256-
if (abi.equals("arm"))
256+
if (abi.equals("arm")) {
257257
expr = xpath.compile("//remotePackage[contains(@path, '" + AVD.TARGET_SDK_ARM + "')" +
258258
"and contains(@path, \"armeabi-v7a\")]");
259-
else
259+
} else if (abi.equals("arm64-v8a")) {
260+
expr = xpath.compile("//remotePackage[contains(@path, '" + AndroidBuild.TARGET_SDK + "')" +
261+
"and contains(@path, \"arm64-v8a\")]");
262+
} else {
260263
expr = xpath.compile("//remotePackage[contains(@path, '" + AndroidBuild.TARGET_SDK + "')" +
261264
"and contains(@path, \"x86\")]");
265+
}
262266

263267
if (wear) {
264268
Document docSysImgWear = db.parse(new URL(repositoryUrl).openStream());
@@ -561,4 +565,4 @@ public void actionPerformed(ActionEvent actionEvent) {
561565
setResizable(false);
562566
setLocationRelativeTo(editor);
563567
}
564-
}
568+
}

0 commit comments

Comments
 (0)