Skip to content

Commit

Permalink
Merge pull request #145 from andreban/android-cli-fix
Browse files Browse the repository at this point in the history
Fix for CLI to work on latest Android CLI Tools
  • Loading branch information
andreban authored Apr 27, 2020
2 parents a8f8a56 + 1269dfc commit 81d0f76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/lib/androidSdk/AndroidSdkTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/spec/lib/androidSdk/AndroidSdkToolsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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());
});
});
Expand Down

0 comments on commit 81d0f76

Please sign in to comment.