@@ -368,22 +368,33 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
368368 }
369369
370370 private getAndroidRuntimeVersionFromProjectDir ( projectDir : string ) : string {
371+ let runtimePackage : string = null ;
371372 let runtimeVersion : string = null ;
372373 if ( projectDir && this . fs . exists ( projectDir ) ) {
373374 const pathToPackageJson = path . join ( projectDir , Constants . PACKAGE_JSON ) ;
374375
375376 if ( this . fs . exists ( pathToPackageJson ) ) {
376- const content = this . fs . readJson < INativeScriptProjectPackageJson > ( pathToPackageJson ) ;
377- const scopedRuntime = "@nativescript/android" ;
378- const oldRuntime = "tns-android" ;
379- if ( content ) {
380- if ( content . devDependencies && content . devDependencies [ scopedRuntime ] ) {
381- runtimeVersion = content . devDependencies [ scopedRuntime ] ;
382- } else if ( content . nativescript && content . nativescript [ oldRuntime ] && content . nativescript [ oldRuntime ] . version ) {
383- runtimeVersion = content && content . nativescript && content . nativescript [ oldRuntime ] && content . nativescript [ oldRuntime ] . version ;
384- }
385- }
386-
377+ const content = this . fs . readJson < INativeScriptProjectPackageJson > ( pathToPackageJson ) ;
378+ const scopedRuntime = "@nativescript/android" ;
379+ const oldRuntime = "tns-android" ;
380+ if ( content ) {
381+ if ( content . devDependencies && content . devDependencies [ scopedRuntime ] ) {
382+ runtimePackage = scopedRuntime ;
383+ runtimeVersion = content . devDependencies [ scopedRuntime ] ;
384+ } else if ( content . nativescript && content . nativescript [ oldRuntime ] && content . nativescript [ oldRuntime ] . version ) {
385+ runtimePackage = oldRuntime ;
386+ runtimeVersion = content && content . nativescript && content . nativescript [ oldRuntime ] && content . nativescript [ oldRuntime ] . version ;
387+ }
388+ }
389+
390+ }
391+ }
392+
393+ if ( runtimeVersion && runtimeVersion . includes ( 'tgz' ) ) {
394+ try {
395+ runtimeVersion = require ( `${ runtimePackage } /package.json` ) . version ;
396+ } catch ( err ) {
397+ runtimeVersion = null ;
387398 }
388399 }
389400
0 commit comments