Reputation: 90
My Ionic app works fine when running with ionic serve but when i use the command ionic cordova run android --livereload it doesn't hit on sever and gives error "Failed to load resource: net::ERR_CONNECTION_REFUSED " below is the ionic info
Ionic CLI : 4.12.0
Ionic Framework : @ionic/angular 4.4.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 4 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.7
System:
NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.2
OS : Windows 10
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="[email protected]" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="19" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" /> //latest version
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
</widget>
below is the snapshot that i get when deployed in mobile
Upvotes: 1
Views: 1373
Reputation: 2086
You need something to proxy the localhost:8080 requests from the android device back to your dev box where the livereload server is running.
You can do this through port forwarding via the chrome browser by opening chrome://inspect/#devices
on your dev box, or else configure port forwarding directly on the phone's connection properties itself. I use this to watch traffic via Fiddler on windows dev boxes.
Also, ionic livereload server can be configured to route non-ionic traffic by configuring service proxies.
Upvotes: 1
Reputation: 2243
A temporary fix is to set base href="." in index.html . But your icons will not be loaded.
Permanent Fix:
ionic cordova platform remove android
ionic cordova platform add [email protected]
ionic cordova plugin remove cordova-plugin-ionic-webview
ionic cordova plugin add cordova-plugin-ionic-webview@latest
Upvotes: 0
Reputation: 13125
One option in this scenario is to not pass the -l/-livereload which is for livereload functionality. So just run:
ionic cordova run android
This will then compile the apk and deploy it to your phone, but won't run a web server to watch for changes.
You can still debug with Chrome in this scenario, but if you make a change to the markup and press save it won't automatically reload the app with that change. You would need to run ionic cordova run android
again to rebuild and deploy it to your phone.
On the plus side 1: after the first deploy, subsequent builds are much faster, as a gradle server is started.
On the plus side 2: if you disconnect your USB then you can still use your app. With a livereload deployed app it breaks once you disconnect.
I would actually really like to solve your problem as well. As I move around coworking spaces sometimes it seems that the network is locked down somehow and just is blocking certain ports. I haven't figured out exactly why or if there is a workaround for this.
Upvotes: 3