Repository navigation
fix(doctor): handle wildcard android runtime version without crashing #6245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,10 +38,8 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo { | |
| ]; | ||
|
|
||
| const isRuntimeVersionLessThan = (targetVersion: string) => { | ||
| return ( | ||
| runtimeVersion && | ||
| semver.lt(semver.coerce(runtimeVersion), targetVersion) | ||
| ); | ||
| const coercedVersion = semver.coerce(runtimeVersion); | ||
| return coercedVersion && semver.lt(coercedVersion, targetVersion); | ||
| }; | ||
|
|
||
| if (isRuntimeVersionLessThan("6.1.0")) { | ||
|
|
@@ -225,6 +223,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo { | |
|
|
||
| if ( | ||
| runtimeMinVersion && | ||
| semver.valid(runtimeVersion) && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check compatibility for valid runtime ranges. With Java 10 and runtime
|
||
| semver.lt(runtimeVersion, runtimeMinVersion) | ||
| ) { | ||
| warning = | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legacy
tns-androidwildcards disable the runtime target cap.When
nativescript["tns-android"].versionis"*",getAndroidRuntimePackageFromProjectDirreturns"*"without reading the installed package.semver.coerce("*")returnsnull, soisRuntimeVersionLessThanreturnsnullfor both thresholds andgetSupportedTargetsskips the slice. Every target up toandroid-37is offered, even when the installed runtime is older. For example, a 6.0 runtime supports targets only up toandroid-28. The scoped@nativescript/androidentry resolves the installed package, so the two entries handle the same wildcard differently.Before this change, the same input made
semver.ltthrow. The change removes the crash but leaves the target list unfiltered.Resolve the installed
tns-androidpackage for the legacy entry in the same way as the scoped entry. An unresolved wildcard must not silently remove the target cap. Choose and document the fallback for that case explicitly.