Skip to content

Commit ce11482

Browse files
authored
Merge pull request #1135 from AndreMiras/feature/command_line_tools
⬆️ Migrates to Command line tools
2 parents 697139d + 435d6a2 commit ce11482

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

buildozer/targets/android.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# because it doesn't seem to matter much, it is normally correct to
4545
# download once then update all the components as buildozer already
4646
# does.
47-
DEFAULT_SDK_TAG = '4333796'
47+
DEFAULT_SDK_TAG = '6514223'
4848

4949
DEFAULT_ARCH = 'armeabi-v7a'
5050

@@ -159,8 +159,11 @@ def p4a_recommended_android_ndk(self):
159159
def _sdkmanager(self, *args, **kwargs):
160160
"""Call the sdkmanager in our Android SDK with the given arguments."""
161161
# Use the android-sdk dir as cwd by default
162-
kwargs['cwd'] = kwargs.get('cwd', self.android_sdk_dir)
163-
command = self.sdkmanager_path + ' ' + ' '.join(args)
162+
android_sdk_dir = self.android_sdk_dir
163+
kwargs['cwd'] = kwargs.get('cwd', android_sdk_dir)
164+
sdkmanager_path = self.sdkmanager_path
165+
sdk_root = f"--sdk_root={android_sdk_dir}"
166+
command = f"{sdkmanager_path} {sdk_root} " + ' '.join(args)
164167
return_child = kwargs.pop('return_child', False)
165168
if return_child:
166169
return self.buildozer.cmd_expect(command, **kwargs)
@@ -372,18 +375,18 @@ def _install_android_sdk(self):
372375

373376
self.buildozer.info('Android SDK is missing, downloading')
374377
if platform in ('win32', 'cygwin'):
375-
archive = 'sdk-tools-windows-{}.zip'.format(DEFAULT_SDK_TAG)
378+
archive = 'commandlinetools-win-{}_latest.zip'.format(DEFAULT_SDK_TAG)
376379
elif platform in ('darwin', ):
377-
archive = 'sdk-tools-darwin-{}.zip'.format(DEFAULT_SDK_TAG)
380+
archive = 'commandlinetools-mac-{}_latest.zip'.format(DEFAULT_SDK_TAG)
378381
elif platform.startswith('linux'):
379-
archive = 'sdk-tools-linux-{}.zip'.format(DEFAULT_SDK_TAG)
382+
archive = 'commandlinetools-linux-{}_latest.zip'.format(DEFAULT_SDK_TAG)
380383
else:
381384
raise SystemError('Unsupported platform: {0}'.format(platform))
382385

383386
if not os.path.exists(sdk_dir):
384387
os.makedirs(sdk_dir)
385388

386-
url = 'http://dl.google.com/android/repository/'
389+
url = 'https://dl.google.com/android/repository/'
387390
self.buildozer.download(url,
388391
archive,
389392
cwd=sdk_dir)
@@ -524,8 +527,10 @@ def _android_update_sdk(self, *sdkmanager_commands):
524527
# This leads to a stderr "Broken pipe" message which is harmless,
525528
# but doesn't look good on terminal, hence redirecting to /dev/null
526529
yes_command = 'yes 2>/dev/null'
527-
command = '{} | {} --licenses'.format(
528-
yes_command, self.sdkmanager_path)
530+
android_sdk_dir = self.android_sdk_dir
531+
sdkmanager_path = self.sdkmanager_path
532+
sdk_root = f"--sdk_root={android_sdk_dir}"
533+
command = f"{yes_command} | {sdkmanager_path} {sdk_root} --licenses"
529534
self.buildozer.cmd(command, cwd=self.android_sdk_dir)
530535
else:
531536
kwargs['show_output'] = True
@@ -573,7 +578,7 @@ def _install_android_packages(self):
573578
if self.buildozer.state.get(cache_key, None) == cache_value:
574579
return True
575580

576-
# 1. update the tool and platform-tools if needed
581+
# 1. update the platform-tools package if needed
577582

578583
skip_upd = self.buildozer.config.getbooldefault(
579584
'app', 'android.skip_update', False)
@@ -582,7 +587,7 @@ def _install_android_packages(self):
582587
self.buildozer.info('Installing/updating SDK platform tools if necessary')
583588

584589
# just calling sdkmanager with the items will install them if necessary
585-
self._android_update_sdk('tools', 'platform-tools')
590+
self._android_update_sdk('platform-tools')
586591
self._android_update_sdk('--update')
587592
else:
588593
self.buildozer.info('Skipping Android SDK update due to spec file setting')

tests/targets/test_android.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,12 @@ def test_install_android_sdk(self, platform):
253253
assert m_file_exists.call_args_list == [
254254
mock.call(self.target_android.android_sdk_dir)
255255
]
256-
archive = "sdk-tools-{platform}-4333796.zip".format(platform=platform)
256+
platform_map = {"linux": "linux", "darwin": "mac"}
257+
platform = platform_map[platform]
258+
archive = "commandlinetools-{platform}-6514223_latest.zip".format(platform=platform)
257259
assert m_download.call_args_list == [
258260
mock.call(
259-
"http://dl.google.com/android/repository/",
261+
"https://dl.google.com/android/repository/",
260262
archive,
261263
cwd=mock.ANY,
262264
)

0 commit comments

Comments
 (0)