Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,20 @@ describe('androidSDK', () => {
androidSDK.runAutomaticFix({loader, environmentInfo});
expect(logSpy).toHaveBeenCalledTimes(1);
});

it('returns true if a build.gradle is not found', async () => {
// To avoid having to provide fake versions for all the Android SDK tools
// @ts-ignore
environmentInfo.SDKs['Android SDK'] = {
'Build Tools': ['28.0.3'],
};
((execa as unknown) as jest.Mock).mockResolvedValue({
stdout: 'build-tools;28.0.3',
});

cleanup('android/build.gradle');

const diagnostics = await androidSDK.getDiagnostics(environmentInfo);
expect(diagnostics.needsToBeFixed).toBe(true);
});
});
12 changes: 4 additions & 8 deletions packages/cli/src/commands/doctor/healthchecks/androidSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const getBuildToolsVersion = (): string => {

const buildToolsVersionEntry = 'buildToolsVersion';

if (!fs.existsSync(gradleBuildFilePath)) {
return 'Not Found';
}

// Read the content of the `build.gradle` file
const gradleBuildFile = fs.readFileSync(gradleBuildFilePath, 'utf-8');

Expand Down Expand Up @@ -45,14 +49,6 @@ export default {
? SDKs['Android SDK']
: SDKs['Android SDK']['Build Tools'];

if (!requiredVersion) {
return {
versions: buildTools,
versionRange: undefined,
needsToBeFixed: true,
};
}

const isAndroidSDKInstalled = Array.isArray(buildTools);

const isRequiredVersionInstalled = isAndroidSDKInstalled
Expand Down