Description
Description:
When trying to launch emulator with Ionic 4 project, I am getting errors.
I am running command in VS Code bash command line:
ionic cordova emulate android --livereload --verbose
I am getting the following error last time -
[cordova] Command finished with error code 0: C:\Users\Gary\AppData\Local\Android\Sdk\platform-tools\adb.exe -s,emulator-5554,shell,am,start,-W,-a,android.intent.action.MAIN,-nio.ionic.starter/.MainActivity
Steps to Reproduce:
- Download My Github repo: https://github.com/gchan82/heartstoneLibApp
- run npm install
+/-3. launch android studio emulator (Nexus 6, API 28 or Pixel 2, API 23) - run: ionic cordova emulate android --livereload --verbose
- You will see errors (on Windows 8.1)
If I do not perform part 3 above, I get this constantly looping:
[cordova] Command finished with error code 1: C:\Users\Gary\AppData\Local\Android\Sdk\platform-tools\adb.exe -s,emulator-5584,shell,getprop,dev.bootcomplete
[cordova] Running adb shell command "getprop dev.bootcomplete" on target emulator-5584...
[cordova] Running command: C:\Users\Gary\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5584 shell getprop dev.bootcomplete
Output:
Emulator shows: System UI isn't responding X Close app, or Wait.
Emulator shows: Application Error - The connection to the server was unsuccessful (http://192.168.103.129:8100)
Upon clicking "OK", screen turns white.
When I ctrl+c to stop the process, I get this error:
ionic:cli-framework:utils:process error while killing process tree for 7700: { Error: Command failed: taskkill /pid 7700 /T /F
ionic:cli-framework:utils:process ERROR: The process "7700" not found.
ionic:cli-framework:utils:process
ionic:cli-framework:utils:process at ChildProcess.exithandler (child_process.js:275:12)
ionic:cli-framework:utils:process at emitTwo (events.js:126:13)
ionic:cli-framework:utils:process at ChildProcess.emit (events.js:214:7)
ionic:cli-framework:utils:process at maybeClose (internal/child_process.js:925:16)
ionic:cli-framework:utils:process at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
ionic:cli-framework:utils:process killed: false,
ionic:cli-framework:utils:process code: 128,
ionic:cli-framework:utils:process signal: null,
ionic:cli-framework:utils:process cmd: 'taskkill /pid 7700 /T /F' } +2s
ionic:cli-framework:utils:process onBeforeExit handler: error from function: { Error: Command failed: taskkill /pid 7700 /T /F
ionic:cli-framework:utils:process ERROR: The process "7700" not found.
ionic:cli-framework:utils:process
ionic:cli-framework:utils:process at ChildProcess.exithandler (child_process.js:275:12)
ionic:cli-framework:utils:process at emitTwo (events.js:126:13)
ionic:cli-framework:utils:process at ChildProcess.emit (events.js:214:7)
ionic:cli-framework:utils:process at maybeClose (internal/child_process.js:925:16)
ionic:cli-framework:utils:process at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
ionic:cli-framework:utils:process killed: false,
ionic:cli-framework:utils:process code: 128,
ionic:cli-framework:utils:process signal: null,
ionic:cli-framework:utils:process cmd: 'taskkill /pid 7700 /T /F' } +12ms
ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 0) +11ms
My ionic info
:
ionic (Ionic CLI) : 4.3.1 (C:\Users\Gary\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.3
@angular-devkit/build-angular : 0.7.4
@angular-devkit/schematics : 0.7.4
@angular/cli : 6.1.4
@ionic/angular-toolkit : not installed
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, browser 5.0.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.5, (and 3 other plugins)
System:
Android SDK Tools : 26.1.1 (C:/Users/Gary/AppData/Local/Android/sdk)
NodeJS : v8.11.4 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 8.1
Other Information:
I have tried updating adb.exe, & updating android studio.
I have tried:
ionic cordova platform rm android
ionic cordova platform add android
Updating to Nexus 6, API 28 (was using Pixel 2, API 23)
Activity
adamduren commentedon Mar 5, 2019
Same here
ionic info
output belowadamduren commentedon Mar 5, 2019
To add more information. The livereload option is looking for a server on port
8100
when it should be using the port specified inangular.json
(4200). I tried updating the command to manually specify the port but to no availionic cordova run android -l -p 4200 --address 0.0.0.0
.I suspected the angular server is not listening on all interfaces which I confirmed by trying to go to the app from my mobile web browser. Next I updated the
ionic-cordova-serve
task inangular.json
and added"host": "0.0.0.0"
. This also had no effect.My best guess is this functionality got passed over in the
ionic@4
upgrade. Would be nice to know if anyone else has had success with this.adamduren commentedon Mar 5, 2019
Also had to add the following to my
config.xml
file to get past anet::ERR_CLEARTEXT_NOT_PERMITTED
error popup.imhoffd commentedon Mar 6, 2019
@adamduren Those sound unrelated to the original issue (emulator not working on Windows 8). Would you mind creating a new issue (or issues, if there are multiple) and including command output?
adamduren commentedon Mar 6, 2019
@dwieeb I think the original issue is misleadingly described and it is indeed
related.
I am getting the same "Application Error - The connection to the server was unsuccessful (http://192.168.103.129:8100)" message but instead of it being on an emulator it's on my device.
Instead of it being unrelated I believe it instead suggests that the problem is independent of wether it's on a device or emulator.
Tomorrow I will recreate the issue on the emulator as well to prove the theory.
[-]Unable to launch emulator in Ionic 4 on Win8.1[/-][+]Application Error - The connection to the server was unsuccessful [/+]imhoffd commentedon Mar 6, 2019
Thanks for clarifying!
Are you able to see your app on the 8100 port if you open your browser to the URL (or
http://localhost:8100
)? If so, it is likely unrelated to the port configuration and more of an issue with your device or emulator not being able to use your computer's LAN IP. The device has to be on the same wifi network as the computer (which is not a concern with emulators).You can also use livereload with port forwarding. Since it sounds like you're using android, you can use
adb reverse tcp:8100 tcp:8100
(adb docs) and then runionic cordova run
with--address=localhost
(cli docs).As for the 4200/8100 disparity: the Ionic CLI does not read
angular.json
. It assigns a port programmatically; i.e. it will use 8100, then 8101 if 8100 is in use. I believe hard-coding a port to use for an app is not supported, but it could be made into a feature request. Since we always pass--port
to the Angular CLI, it probably doesn't use the configured port inangular.json
.If you notice any disparity in configuring
ng run app:serve
vsng run app:ionic-cordova-serve
, it is likely an issue with the locally installed@ionic/angular-toolkit
.adamduren commentedon Mar 6, 2019
@dwieeb thanks for the advice. I was able to resolve my issue, although I'm not sure it will resolve the OPs. Here are some notes based on that.
My first issue was the
net::ERR_CLEARTEXT_NOT_PERMITTED
which I posted above. I'm not sure if Ionic is supposed to add this automatically but according to this SO post it's required in Android 8+ without HTTPS.The resolution for the second issue where I got the "Application Error - The connection to the server was unsuccessful" message to me is still unclear. Uninstalling the app beforehand seems to have made the difference but I have been unable to get back to the broken state since so that's probably a coincidence.
Anyways for me on OSX I was able to get it working on both the emulator and on a device. The only strange behavior is that I have to manually launch the app from the app launcher. The CLI . says
LAUNCH SUCCESS
but really the only thing that happens is the long press of the background that reveals the background options.imhoffd commentedon Mar 6, 2019
@adamduren Sounds like an underlying Cordova issue. I'm curious if using
native-run
instead of Cordova run will work better for you. To try the (experimental) alternative flow,npm i -g native-run
, then:miqmago commentedon Apr 7, 2019
Same problem with
--native-run
imhoffd commentedon Apr 8, 2019
@miqmago I doubt it's the exact same problem. Please create a new issue and fill out the template and post full command output.
miqmago commentedon Apr 8, 2019
I could solve
net::ERR_CLEARTEXT_NOT_PERMITTED
problem with @adamduren #3759 (comment) solutionconfig.xml
file, which createdandroid:usesCleartextTraffic="true"
option insideAndroidmanifest.xml
.Have to note that the application didn't compile with modified
config.xml
so I had to remove the modifications while keepingAndroidmanifest.xml
updated so the application compiled correctly. If I remove the optionandroid:usesCleartextTraffic="true"
fromAndroidManifest.xml
, the problem appears again.Not sure if the problem is related, but after deep googling for
net::ERR_CLEARTEXT_NOT_PERMITTED
this is the only place where I found a solution.pisouris commentedon Apr 10, 2019
Yes, to me, this place is the only clears about the solution. Thanks
I changed the AndroidManifest.xml like miqmago said it and it worked without problem.
monisamjad commentedon Apr 22, 2019
I also did the same as @miqmago and @adamduren suggested. Working fine now.
14 remaining items