1

I have created a new Ionic 3 app, i haven't touched it yet, it works fine on browser however when i tried to build and run it on a actual android device, the generated apk output is always

"Couldn't connect to the server. (http://localhost:8080/)"

see: https://user-images.githubusercontent.com/22809323/43546424-0974fb28-95f2-11e8-92be-1d4099039f85.png

Here's the process i've made

-ionic start apktest blank -cd apktest -ionic cordova platform add android -ionic cordova build android -ionic cordova run android

PS: I already have those android sdk and java

Can anybody enlighten me about this issue? Thanks

1
  • Additional: What i have found is that, the app actually works however when i tested it out on android version 4.4.2 kitkat. it shows the above issue. Commented Aug 25, 2018 at 8:01

2 Answers 2

3

You are getting this error message because your app probably uses a plugin that does not support Android 4.x.

Run ionic cordova plugins to check if it contains an entry for the plugin cordova-plugin-ionic-webview with version 2.x.

If it exists, you can downgrade it plugin to the last version that supported Android 4.x:

ionic cordova plugin add [email protected] 

Some background information: This plugin used to apply only to iOS, where it replaced the UIWebView with WKWebView, but on July 23rd 2018 they released version 2.0 of the plugin, that also included changes to the webview used on Android. The Android webview now uses a local webserver at localhost:8080 to show your app instead of requesting the files directly from the file system.

More elaborate information and alternative solutions:
https://ionic.zone/debug/ionic-and-android-4

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @janpio, this answers my question. Thanks again
0

I had a similar problem before.

I modify the file config.xml adding the following inside the platform tag.

 <preference name=“loadUrlTimeoutValue” value=“700000” /> 

1 Comment

i have tried this one, however it still does not work on my end :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.