Skip to content

Commit 178abc2

Browse files
feat: remove requirement for Android Support Repository local installation
In the past there was a requirement to have a local installation of the Android Support Repository in order to use libraries from there. However, since some time, the new versions are not downloaded locally and they must be used from the Google repository. Currently this is not possible in NativeScript as {N} CLI always passes the Support Library version to gradle based on the local installation. Remove the requirement for local installation and never pass the version to gradle. This way the apps will use the value specified in the `build.gradle` and they can overwrite it in `app.gradle`. Update nativescript-doctor to latest version, which allows building project without local Androud Support Repository
1 parent 6310203 commit 178abc2

7 files changed

+16
-52
lines changed

lib/android-tools-info.ts

-27
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
3131
infoData.compileSdkVersion = this.getCompileSdkVersion();
3232
infoData.buildToolsVersion = this.getBuildToolsVersion();
3333
infoData.targetSdkVersion = this.getTargetSdk();
34-
infoData.supportRepositoryVersion = this.getAndroidSupportRepositoryVersion();
3534
infoData.generateTypings = this.shouldGenerateTypings();
3635

3736
this.toolsInfo = infoData;
@@ -203,32 +202,6 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
203202
return buildToolsVersion;
204203
}
205204

206-
private getAppCompatRange(): string {
207-
const compileSdkVersion = this.getCompileSdkVersion();
208-
let requiredAppCompatRange: string;
209-
if (compileSdkVersion) {
210-
requiredAppCompatRange = `>=${compileSdkVersion} <${compileSdkVersion + 1}`;
211-
}
212-
213-
return requiredAppCompatRange;
214-
}
215-
216-
private getAndroidSupportRepositoryVersion(): string {
217-
let selectedAppCompatVersion: string;
218-
const requiredAppCompatRange = this.getAppCompatRange();
219-
if (this.androidHome && requiredAppCompatRange) {
220-
const pathToAppCompat = path.join(this.androidHome, "extras", "android", "m2repository", "com", "android", "support", "appcompat-v7");
221-
selectedAppCompatVersion = this.getMatchingDir(pathToAppCompat, requiredAppCompatRange);
222-
if (!selectedAppCompatVersion) {
223-
// get latest matching version, as there's no available appcompat versions for latest SDK versions.
224-
selectedAppCompatVersion = this.getMatchingDir(pathToAppCompat, "*");
225-
}
226-
}
227-
228-
this.$logger.trace(`Selected AppCompat version is: ${selectedAppCompatVersion}`);
229-
return selectedAppCompatVersion;
230-
}
231-
232205
private getLatestValidAndroidTarget(): string {
233206
const installedTargets = this.getInstalledTargets();
234207
return _.findLast(AndroidToolsInfo.SUPPORTED_TARGETS.sort(), supportedTarget => _.includes(installedTargets, supportedTarget));

lib/declarations.d.ts

-5
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,6 @@ interface IAndroidToolsInfoData {
618618
*/
619619
compileSdkVersion: number;
620620

621-
/**
622-
* The latest installed version of Android Support Repository that satisfies CLI's requirements.
623-
*/
624-
supportRepositoryVersion: string;
625-
626621
/**
627622
* The Android targetSdkVersion specified by the user.
628623
* In case it is not specified, compileSdkVersion will be used for targetSdkVersion.

lib/services/android-plugin-build-service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
425425
pluginBuildSettings.pluginDir,
426426
"assembleRelease",
427427
`-PcompileSdk=android-${pluginBuildSettings.androidToolsInfo.compileSdkVersion}`,
428-
`-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`,
429-
`-PsupportVersion=${pluginBuildSettings.androidToolsInfo.supportRepositoryVersion}`
428+
`-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`
430429
];
431430

432431
try {

lib/services/android-project-service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
369369
const compileSdk = androidToolsInfo.compileSdkVersion;
370370
const targetSdk = this.getTargetFromAndroidManifest(configurationFilePath) || compileSdk;
371371
const buildToolsVersion = androidToolsInfo.buildToolsVersion;
372-
const appCompatVersion = androidToolsInfo.supportRepositoryVersion;
373372
const generateTypings = androidToolsInfo.generateTypings;
374373
const buildOptions = [
375374
`-PcompileSdk=android-${compileSdk}`,
376375
`-PtargetSdk=${targetSdk}`,
377376
`-PbuildToolsVersion=${buildToolsVersion}`,
378-
`-PsupportVersion=${appCompatVersion}`,
379377
`-PgenerateTypings=${generateTypings}`
380378
];
381379

npm-shrinkwrap.json

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"minimatch": "3.0.2",
5656
"mkdirp": "0.5.1",
5757
"mute-stream": "0.0.5",
58-
"nativescript-doctor": "1.2.0",
58+
"nativescript-doctor": "1.3.0",
5959
"nativescript-preview-sdk": "0.2.9",
6060
"open": "0.0.5",
6161
"ora": "2.0.0",

test/stubs.ts

-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,6 @@ export class AndroidToolsInfoStub implements IAndroidToolsInfo {
603603
infoData.compileSdkVersion = 23;
604604
infoData.buildToolsVersion = "23";
605605
infoData.targetSdkVersion = 23;
606-
infoData.supportRepositoryVersion = "23";
607606
return infoData;
608607
}
609608

0 commit comments

Comments
 (0)