Repository navigation
Error while trying to start application on Android emulator with API level Q #4451
Description
Activity
- changed the title
[-]Error while trying to start application ... Error is: Invalid Version: null[/-][+]Error while trying to start application on Android emulator with API level Q[/+]on Mar 20, 2019 - added a commit that references this issue
on Mar 25, 2019 - added a commit that references this issue
on Mar 28, 2019 This issue is persisting for me with Pixel 2 API 28 and Pixel 2 API 29, both running Android Q (10.0 x86).
$ nativescript --version 7.0.11
Thanks for the pointer @NathanaelA. Is Android Q a beta release, do you mean? It’s a bit unclear to me. I also hadn’t expected to have been automatically given a beta release by Android Studio’s device / ADB manager.
One other thing that you said confuses me; API 28 is NOT Q, so if your Pixel 28 emulator is returning Q and API 28, then something is wrong with that emulator. API 29=Q, API 28=P
I could well have misread the API 28 one; maybe disregard that. The main thing is that it suffers the very same nondescript error on both my 28 and 29 virtual devices.
Here's what my 29 device shows in AVD in Android Studio 4.1.1:
And, when trying to create a new one:
Not clear to me whether I'm getting a beta by accident.
$ tns device log Searching for devices... Connected devices & emulators ┌───┬────────────────┬──────────┬──────────────────────────────────────┬──────────┬───────────┬─────────────────┐ │ # │ Device Name │ Platform │ Device Identifier │ Type │ Status │ Connection Type │ │ 1 │ Pixel_2_API_29 │ Android │ emulator-5554 │ Emulator │ Connected │ Local │ │ 2 │ iPhone 8 Plus │ iOS │ F7839325-EC09-4316-A9ED-165EE3E597AE │ Emulator │ Connected │ Local │ └───┴────────────────┴──────────┴──────────────────────────────────────┴──────────┴───────────┴─────────────────┘
How did you print out your
device.deviceInfo? Was that just by shoving aconsole.log()into the CLI code?@NathanaelA I've been looking into this. deviceInfo may have been a red herring. I understood that the error was ultimately coming from a call to
semver, so I put a trace intosemver.js, then ran atns plugin addcommand:Trace: [CLI] here, boss at new SemVer (/usr/local/lib/node_modules/nativescript/node_modules/semver/classes/semver.js:22:15) at compare (/usr/local/lib/node_modules/nativescript/node_modules/semver/functions/compare.js:3:32) at Object.gt (/usr/local/lib/node_modules/nativescript/node_modules/semver/functions/gt.js:2:29) at PluginsService.isPluginDataValidForPlatform (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:415:29) at PluginsService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:66:26) at Generator.next (<anonymous>) at /usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:8:71 at new Promise (<anonymous>) at __awaiter (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:4:12) at action (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:65:83)So the problem evidently begins here:
return runtimePackage.version; > console.log(`runtimePackage`, runtimePackage); < { name: '@nativescript/android', version: null }
So it's getting
nullfor the Android runtime version...Here is the
package.jsonfor my app (it is made from the official NativeScript plugin seed, but note that I hoist the@nativescript/androiddependency, as I comment on later):{ "main": "app.js", "dependencies": { "@nativescript/android": "file:../../node_modules/@nativescript/android", "@nativescript/core": "file:../../node_modules/@nativescript/core", "@nativescript/ios": "file:../../node_modules/@nativescript/ios", "@react-navigation/core": "file:../../node_modules/@react-navigation/core", "react": "file:../../node_modules/react", "react-nativescript": "file:../../node_modules/react-nativescript", "react-nativescript-navigation": "file:../../node_modules/react-nativescript-navigation", }, "devDependencies": { "@babel/core": "file:../../node_modules/@babel/core", "@nativescript/webpack": "~3.0.0", "@nativescript/types": "file:../../node_modules/@nativescript/types", "@pmmmwh/react-refresh-webpack-plugin": "file:../../node_modules/@pmmmwh/react-refresh-webpack-plugin", "@types/react": "file:../../node_modules/@types/react", "babel-loader": "file:../../node_modules/babel-loader", "fork-ts-checker-webpack-plugin": "file:../../node_modules/fork-ts-checker-webpack-plugin", "react-refresh": "file:../../node_modules/react-refresh", "typescript": "file:../../node_modules/typescript" } }... these refer to the monorepo dependencies. The monorepo's
package.jsonis:{ "name": "plugins", "version": "0.0.0", "license": "MIT", "scripts": { "postinstall": "node ./node_modules/husky/lib/installer/bin install && patch-package", "setup": "npx rimraf node_modules package-lock.json dist tmp && npm i && ts-patch install", "start": "nps", "add": "nx g @nativescript/plugin-tools:add-package", "add-angular": "nx g @nativescript/plugin-tools:add-angular", "config": "nx g @nativescript/plugin-tools:config", "publish-packages": "nx g @nativescript/plugin-tools:publish" }, "private": true, "devDependencies": { "@angular/animations": "~10.1.0", "@angular/common": "~10.1.0", "@angular/compiler": "~10.1.0", "@angular/compiler-cli": "~10.1.0", "@angular/core": "~10.1.0", "@angular/forms": "~10.1.0", "@angular/platform-browser": "~10.1.0", "@angular/platform-browser-dynamic": "~10.1.0", "@angular/router": "~10.1.0", "@babel/core": "^7.4.5", "@nativescript/android": "7.0.1", "@nativescript/angular": "~10.1.0", "@nativescript/core": "~7.0.0", "@nativescript/ios": "7.0.6", "@nativescript/plugin-tools": "~1.0.0", "@nativescript/types": "~7.0.0", "@nativescript/webpack": "~3.0.0", "@ngtools/webpack": "~10.1.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.0-beta.5", "@react-navigation/core": "^5.13.2", "@types/react": "16.9.34", "babel-loader": "8.0.6", "fork-ts-checker-webpack-plugin": "^5.1.0", "husky": "^4.3.0", "nativescript-vue": "~2.8.0", "nativescript-vue-template-compiler": "~2.8.0", "ng-packagr": "~10.1.0", "patch-package": "^6.2.2", "react": "^16.13.1", "react-nativescript": "^2.1.0", "react-nativescript-navigation": "^2.0.1", "react-refresh": "^0.8.3", "rxjs": "~6.6.0", "typescript": "~4.0.0", "zone.js": "0.11.1" }, "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "**/*": [ "nx format:write --files" ] } }So might this only affect monorepos? Unlike the NativeScript plugin seed, I've chosen to hoist the Android dependency in mine, as I couldn't see why it couldn't be hoistable – maybe that led to something breaking?
So might this only affect monorepos? Unlike the NativeScript plugin seed, I've chosen to hoist the Android dependency in mine, as I couldn't see why it couldn't be hoistable – maybe that led to something breaking?
Nope, I tried "unhoisting" it, and it still faces the same error.
After unhoisting my
@nativescript/androiddependency, and runningtns clean, I triedtns doctor:$ tns doctor ✔ Getting environment information No issues were detected. ✔ Your ANDROID_HOME environment variable is set and points to correct directory. ✔ Your adb from the Android SDK is correctly installed. ✔ The Android SDK is installed. ✔ A compatible Android SDK for compilation is found. ✔ Javac is installed and is configured properly. ✔ The Java Development Kit (JDK) is installed and is configured properly. ✔ Xcode is installed and is configured properly. ✔ xcodeproj is installed and is configured properly. ✔ CocoaPods are installed. ✔ CocoaPods update is not required. ✔ CocoaPods are configured properly. ✔ Your current CocoaPods version is newer than 1.0.0. ✔ Python installed and configured correctly. ✔ The Python 'six' package is found. ✔ Xcode version 12.2.0 satisfies minimum required version 10. ✔ Getting NativeScript components versions information... ✔ Component nativescript has 7.0.11 version and is up to date. ✔ Component @nativescript/core has 7.0.13 version and is up to date. ✖ Component @nativescript/ios is not installed. ✖ Component @nativescript/android is not installed. $ tns platform add android@7.0.1 Copying template files... Platform android successfully added. v7.0.1 ✔ Getting environment information No issues were detected. ✔ Your ANDROID_HOME environment variable is set and points to correct directory. ✔ Your adb from the Android SDK is correctly installed. ✔ The Android SDK is installed. ✔ A compatible Android SDK for compilation is found. ✔ Javac is installed and is configured properly. ✔ The Java Development Kit (JDK) is installed and is configured properly. ✔ Xcode is installed and is configured properly. ✔ xcodeproj is installed and is configured properly. ✔ CocoaPods are installed. ✔ CocoaPods update is not required. ✔ CocoaPods are configured properly. ✔ Your current CocoaPods version is newer than 1.0.0. ✔ Python installed and configured correctly. ✔ The Python 'six' package is found. ✔ Xcode version 12.2.0 satisfies minimum required version 10. ✔ Getting NativeScript components versions information... ✔ Component nativescript has 7.0.11 version and is up to date. ✔ Component @nativescript/core has 7.0.13 version and is up to date. ✖ Component @nativescript/ios is not installed. ✖ Component @nativescript/android is not installed.
Pretty alarming that it still can't find
@nativescript/android...Note that the
[CLI!]logs were added by myself into the NativeScript CLI.$ tns plugin add my-cool-plugin npm WARN react-reconciler@0.25.1 requires a peer of react@^16.13.1 but none is installed. You must install peer dependencies yourself. npm WARN @0.0.1 No description npm WARN @0.0.1 No repository field. npm WARN @0.0.1 No license field. + @nativescript-community/my-cool-plugin@1.0.0 updated 1 package and audited 901 packages in 4.853s 35 packages are looking for funding run `npm fund` for details found 0 vulnerabilities [CLI!] projectData.projectDir /Users/jamie/Documents/git/my-monorepo/apps/demo-react [CLI!] platform android [CLI!] runtimePackage { name: '@nativescript/android', version: null } [CLI!] installedFrameworkVersion null [CLI!] pluginPlatformsData { ios: '6.0.0', android: '6.0.0' } [CLI!] pluginPlatformsData[platform] 6.0.0 Trace: [CLI!] here boss at new SemVer (/usr/local/lib/node_modules/nativescript/node_modules/semver/classes/semver.js:22:15) at compare (/usr/local/lib/node_modules/nativescript/node_modules/semver/functions/compare.js:3:32) at Object.gt (/usr/local/lib/node_modules/nativescript/node_modules/semver/functions/gt.js:2:29) at PluginsService.isPluginDataValidForPlatform (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:421:29) at PluginsService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:66:26) at Generator.next (<anonymous>) at /usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:8:71 at new Promise (<anonymous>) at __awaiter (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:4:12) at action (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:65:83) Invalid Version: null
@NathanaelA Moved to here: #5444
Reacted by Nathanael Anderson



@neil-119 commented on Wed Mar 20 2019
Environment
Provide version numbers for the following components (information can be retrieved by running
tns infoin your project folder or by inspecting thepackage.jsonof the project):Describe the bug
After
tns run android, the application runs when opened manually, but we are unable to debug or see any console logs because the app fails to start:Below is a log trace from the newly created app:
https://gist.githubusercontent.com/neil-119/e8ecdc5d3d7036c78005033f3532ffb3/raw/632599f919cbf9cc360498d6103c8c9b65695c59/log.txt
To Reproduce
Expected behavior
Application runs without error
Sample project
Default project when running
tns createAdditional context
Note that we are running the latest beta build of Android Q on Google Pixel 3 XL.
@neil-119 commented on Wed Mar 20 2019
Update - works fine on our Android 9 (i.e. Android P) device. This issue seems to be associated with Android Q (tried on two different Android Q devices).
@NathanaelA commented on Wed Mar 20 2019
@neil-119 -
Question for you; can you try a couple things if you have time.tns create test --js && cd testthentns run android(i.e. try just a simple base app)@NathanaelA commented on Wed Mar 20 2019
I ran a couple tests on an Q emulator (don't have a real Q device).
The message:
Error is: Invalid Version: nullis from TNS CLI not the emulator. And the app runs fine, but logging from TNS is halted because of this error.
The easier way to see this is just do a
tns device logThe actual device.deviceInfo retrieved from my emulator is:
The callstack is at:
On logcat-helper.js line 87;
const isLogcatPidSupported = !!device.deviceInfo.version && semver.gte(semver.coerce(device.deviceInfo.version), minAndroidWithLogcatPidSupport);So it is looking at
device.deviceInfo.versionof which version = 'Q' and so semVer throws that error, and of course fails out.@NickIliev.- This issue needs to be moved to the CLI.
@neil-119 - You can do the following on Linux or Mac:
In the meantime you can do
adb logcat | grep JSto see error from another terminal window....