ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

ionic cordova run android --livereload does not work with a default project

Open Zefling opened this issue 5 years ago • 8 comments

I have start a project with this:

nvm install 10.16.3
nvm use 10.16.3
npm install -g ionic
npm install -g cordova
ionic start myApp tabs --cordova
cd myApp
ionic cordova run android --livereload

Without --livereload the app works:

2019-09-30_10h07_50

But with --livereload I have just a white screen and this:

BUILD SUCCESSFUL in 2s
42 actionable tasks: 42 up-to-date
Built the following apk(s):
        C:\test\myApp\platforms\android\app\build\outputs\apk\debug\app-debug.apk
> native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-debug.apk
[native-run] No hardware devices found, attempting emulator...
[native-run] Selected emulator emulator-5554
[native-run] Installing platforms\android\app\build\outputs\apk\debug\app-debug.apk...
[native-run] Starting application activity io.ionic.starter/io.ionic.starter.MainActivity...
[native-run] Run Successful

image

I'm using VScode with Git Bash on Windows 10.

Zefling avatar Sep 30 '19 08:09 Zefling

It's probably a problem with the SDK, it works with ionic cordova run android --device --livereload.

Zefling avatar Sep 30 '19 08:09 Zefling

@Zefling If you see a white screen, the best thing to do is use Chrome DevTools to remotely see the error: https://ionicframework.com/docs/building/android#debugging-android-apps

imhoffd avatar Sep 30 '19 16:09 imhoffd

I also encountered this problem. devtool log nothing and do not load anything from www directory. image this is my development env image

maroon1 avatar Oct 09 '19 08:10 maroon1

Angular 8.0 auto load bundled script by module type if target is set to 2015 in tsconfig.json, so old browser can not load these script.

maroon1 avatar Oct 12 '19 08:10 maroon1

same issue here.

GuidoGagliardini avatar Apr 21 '23 00:04 GuidoGagliardini

Same here ! ionic cordova run android --device --livereload --> cause: ERR_EMPTY_RESPONSE ionic cordova run android --device --> works fine


Ionic:

   Ionic CLI                     : 7.1.1 (C:\Users\Pablo\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.2.8
   @angular-devkit/build-angular : 14.2.3
   @angular-devkit/schematics    : 14.2.3
   @angular/cli                  : 14.2.3
   @ionic/angular-toolkit        : 6.1.0

Cordova:

   Cordova CLI       : 11.0.0
   Cordova Platforms : android 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 9 other plugins)

Utility:

   cordova-res (update available: 0.15.4) : 0.15.2
   native-run (update available: 1.7.2)   : 0.2.8

System:

   Android SDK Tools : 26.1.1 (C:\Users\Pablo\AppData\Local\Android\Sdk\)
   NodeJS            : v18.15.0 (C:\Program Files\nodejs\node.exe)
   npm               : 9.3.1
   OS                : Windows 10

chacabuk avatar May 06 '23 20:05 chacabuk

Is there any solution? I am stuck same issue

Same here ! ionic cordova run android --device --livereload --> cause: ERR_EMPTY_RESPONSE ionic cordova run android --device --> works fine


Ionic:

   Ionic CLI                     : 7.1.1 (C:\Users\Pablo\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.2.8
   @angular-devkit/build-angular : 14.2.3
   @angular-devkit/schematics    : 14.2.3
   @angular/cli                  : 14.2.3
   @ionic/angular-toolkit        : 6.1.0

Cordova:

   Cordova CLI       : 11.0.0
   Cordova Platforms : android 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 9 other plugins)

Utility:

   cordova-res (update available: 0.15.4) : 0.15.2
   native-run (update available: 1.7.2)   : 0.2.8

System:

   Android SDK Tools : 26.1.1 (C:\Users\Pablo\AppData\Local\Android\Sdk\)
   NodeJS            : v18.15.0 (C:\Program Files\nodejs\node.exe)
   npm               : 9.3.1
   OS                : Windows 10

halilpolathalil avatar Nov 12 '23 15:11 halilpolathalil

Is there any solution? I am stuck same issue

Same here ! ionic cordova run android --device --livereload --> cause: ERR_EMPTY_RESPONSE ionic cordova run android --device --> works fine


Ionic:

   Ionic CLI                     : 7.1.1 (C:\Users\Pablo\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.2.8
   @angular-devkit/build-angular : 14.2.3
   @angular-devkit/schematics    : 14.2.3
   @angular/cli                  : 14.2.3
   @ionic/angular-toolkit        : 6.1.0

Cordova:

   Cordova CLI       : 11.0.0
   Cordova Platforms : android 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 9 other plugins)

Utility:

   cordova-res (update available: 0.15.4) : 0.15.2
   native-run (update available: 1.7.2)   : 0.2.8

System:

   Android SDK Tools : 26.1.1 (C:\Users\Pablo\AppData\Local\Android\Sdk\)
   NodeJS            : v18.15.0 (C:\Program Files\nodejs\node.exe)
   npm               : 9.3.1
   OS                : Windows 10

Hello! Yesterday I found a solution to this problem. (for android obviously) in folder resources/android/xml/network_security_config.xml

you have to add the IP address of your pc to allow the device to recognize that domain. this is a example.


<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true">192.168.0.5</domain>
    </domain-config>
</network-security-config>

then confirm that your config.xml you have this configuration.


  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" android:usesCleartextTraffic="true" />
        </edit-config>

this is important because set netWorkSecurityConfig and ClearTraffic

and then check proxy config in ionic.config.json and set proxies

 "proxies":[
    {
      "path": "/192.168.0.5",
      "proxyUrl":"http://192.168.0.5:PORT"
    }
  ]

and set the port correctly

sorry, I forgot to clarify that you must run this command in order to run livereload

ionic cordova run android --no-native-run -l --external

I hope you find it helpful

GuidoGagliardini avatar Nov 16 '23 13:11 GuidoGagliardini