From 86bd38bc93cc84941994e38a19b31a96230f9980 Mon Sep 17 00:00:00 2001 From: Andre Bandarra Date: Mon, 27 Apr 2020 10:13:57 +0100 Subject: [PATCH 1/2] Fix for CLI to work on latest Android CLI Tools Setting ANDROID_HOME via should be enough for sdkmanager to work, but version 6200805 of the the Android Command Line tools only work if sdk_root is not set. --- packages/core/src/lib/androidSdk/AndroidSdkTools.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/lib/androidSdk/AndroidSdkTools.ts b/packages/core/src/lib/androidSdk/AndroidSdkTools.ts index 42b0e1f2..1d7a5d46 100644 --- a/packages/core/src/lib/androidSdk/AndroidSdkTools.ts +++ b/packages/core/src/lib/androidSdk/AndroidSdkTools.ts @@ -66,7 +66,10 @@ export class AndroidSdkTools { await util.execInteractive( this.pathJoin(this.getAndroidHome(), '/tools/bin/sdkmanager'), ['--install', - `"build-tools;${BUILD_TOOLS_VERSION}"`], + `"build-tools;${BUILD_TOOLS_VERSION}"`, + // setting ANDROID_HOME via this.getEnv() should be enough, but version 6200805 of the + // the Android Command Line tools don't work properly if sdk_root is not set. + `--sdk_root="${this.getAndroidHome()}"`], env, ); } From 1269dfc1c6d47c938371aaf806cdf2c1350ee31d Mon Sep 17 00:00:00 2001 From: Andre Bandarra Date: Mon, 27 Apr 2020 10:29:02 +0100 Subject: [PATCH 2/2] Fixes failing AndroidSdkTools tests --- .../src/spec/lib/androidSdk/AndroidSdkToolsSpec.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/src/spec/lib/androidSdk/AndroidSdkToolsSpec.ts b/packages/core/src/spec/lib/androidSdk/AndroidSdkToolsSpec.ts index 6d20d321..a4f25944 100644 --- a/packages/core/src/spec/lib/androidSdk/AndroidSdkToolsSpec.ts +++ b/packages/core/src/spec/lib/androidSdk/AndroidSdkToolsSpec.ts @@ -91,11 +91,14 @@ describe('AndroidSdkTools', () => { describe('#installBuildTools', () => { const tests = [ {platform: 'linux', - expectedAndroidHome: '/home/user/android-sdk/tools/bin/sdkmanager'}, + expectedAndroidHome: '/home/user/android-sdk/', + expectedCwd: '/home/user/android-sdk/tools/bin/sdkmanager'}, {platform: 'darwin', - expectedAndroidHome: '/home/user/android-sdk/tools/bin/sdkmanager'}, + expectedAndroidHome: '/home/user/android-sdk/', + expectedCwd: '/home/user/android-sdk/tools/bin/sdkmanager'}, {platform: 'win32', - expectedAndroidHome: 'C:\\Users\\user\\android-sdk\\tools\\bin\\sdkmanager'}, + expectedAndroidHome: 'C:\\Users\\user\\android-sdk\\', + expectedCwd: 'C:\\Users\\user\\android-sdk\\tools\\bin\\sdkmanager'}, ]; tests.forEach((test) => { @@ -107,8 +110,8 @@ describe('AndroidSdkTools', () => { spyOn(util, 'execInteractive').and.stub(); androidSdkTools.installBuildTools(); expect(util.execInteractive).toHaveBeenCalledWith( - test.expectedAndroidHome, - ['--install', '"build-tools;29.0.2"'], + test.expectedCwd, + ['--install', '"build-tools;29.0.2"', `--sdk_root="${test.expectedAndroidHome}"`], androidSdkTools.getEnv()); }); });