ionic-team / cordova-plugin-ionic-webview

Web View plugin for Cordova, specialized for Ionic apps.
Apache License 2.0
485 stars 393 forks source link

Error with plugin v2.5.1 - net: ERR_CONNECTION_REFUSED (http:/localhost:8080//++/index.html) #429

Closed Adza93 closed 4 years ago

Adza93 commented 5 years ago

Hey everyone!

After performing ionic project migration to platform android 8.0.0 I am facing issue with cordova-plugin-ionic-webview

After I build and run project I get error message:

net: ERR_CONNECTION_REFUSED (http:/localhost:8080//++/index.html)

I have never seen something like this. Am i missing some additional configuration in AndroidManifest.xml?

Project configuration: cli packages: (/usr/local/lib/node_modules) @ionic/cli-utils : 1.19.3 ionic (Ionic CLI) : 3.20.1 global packages: cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) local packages: @ionic/app-scripts : 3.2.3 Cordova Platforms : android 8.0.0 ios 4.3.1 Ionic Framework : ionic-angular 3.9.8

cordova-plugin-ionic-webview 2.5.1 "cordova-plugin-ionic-webview"

I am using plugin version 2.X since I am on Ionic 3.

Please ask if you need any additional info! Thanks for help!

jcesarmobile commented 5 years ago

4.x.x also works with Ionic 3.

Can you provide a sample app? or at least the preferences and plugins in config.xml? looks like something is not right in your end.

Adza93 commented 5 years ago

Hey, thanks for such a quick response!

Sorry for my bad previous info, I forgot to mention that webview plugin 4.X requires iOS native platform to be 11+, and since I am currently running 10 that is unfortunately not possible. I must keep iOS 10 user base for now.

I dont have the sample app but I will try to prepare it. During the time let me give better explanation of what is going on I am migrating cordova platform from android 6.4.0 to 8.0.0. Its also worth mentioning that my current ionic code base is already running on plugin version 2.5.1 and I am not experiencing any issues there.

I have removed cordova android platform and added it. All plugins have been installed successfully and the whole process of building application via ionic cordova build android command, also via android studio is completed successfully.

However I have discovered this issue with very strange localhost url, specifically those stars in URL, that part might be wrong?

when I check ConfigXmlParser.java and CordovaActivity, i get launchUrl initiated with url http:/localhost:8080//++/index.html.

When I realized that this is wrong behaviour (it obviously should be http://localhost:8080/index.html + maybe some other part of url). I have debugged my old project running on cordova android 6.4.0 and just realized that I do not even get webview to instantiate web server via new way (running from local webserver on device, as on iOS), but same method setStartUrl is recieving file:// url with accessing local file on device.

I dont think the problem is with the plugins. By my knowledge none of my other plugins is accessing webview components.

com-intel-security-cordova-plugin 2.0.3 "APP Security API" cordova-open-native-settings 1.4.1 "Native settings" cordova-plugin-advanced-http 2.0.9 "Advanced HTTP plugin" cordova-plugin-android-permissions 1.0.0 "Permissions" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-badge 0.8.3 "Badge" cordova-plugin-brightness 0.1.5 "Brightness" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-console 1.0.5 "Console" cordova-plugin-contacts 3.0.1 "Contacts" cordova-plugin-crypt-file 1.3.3 "CordovaCrypt" cordova-plugin-crypto-file 1.2.1 "Crypt File" cordova-plugin-device 1.1.4 "Device" cordova-plugin-facebook4 1.9.1 "Facebook Connect" cordova-plugin-file 6.0.1 "File" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps" cordova-plugin-inappbrowser 1.7.1 "InAppBrowser" cordova-plugin-ionic-webview 2.5.1 "cordova-plugin-ionic-webview" cordova-plugin-network-information 2.0.3-dev "Network Information" cordova-plugin-screen-orientation 2.0.1 "Screen Orientation" cordova-plugin-secure-storage 2.6.8 "SecureStorage" cordova-plugin-splashscreen 4.0.1 "Splashscreen" cordova-plugin-statusbar 2.2.1 "StatusBar" cordova-plugin-taptic-engine 2.1.0 "Taptic Engine" cordova-plugin-vibration 3.1.0 "Vibration" cordova-plugin-whitelist 1.3.1 "Whitelist" cordova-plugin-x-socialsharing 5.2.1 "SocialSharing" es6-promise-plugin 4.1.0 "Promise" ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin" ionic-plugin-keyboard 2.2.1 "Keyboard" phonegap-plugin-mobile-accessibility 1.0.5-dev "Mobile Accessibility"

This behaviour that I am having on android platform 6.4.0 and webview plugin 2.5.1 where application initializes with local files, not via web server, that is unexpected behavior right? Is there any paramether that needs to be provided in config.xml to be able to override this local webserver on android and use file:// structure? if again thats an option with 2.X :)

Thanks for helping out! if i can give additional info I am here. I will try with sample project soon!

jcesarmobile commented 5 years ago

Do you have "http:/localhost:8080//++/index.html" in the config.xml in some place? Or if you do a search in your project you find it somewhere?

Posting the full config.xml (minus some private info as author, app name, app id, etc)

Adza93 commented 5 years ago

I have tried that already, unfortunately, no luck.

EDIT (xml formatting removed so content can be visible)

Informations that matter cordova-plugin-webview that are in config.xml and I am using are:

feature name="CDVWKWebViewEngine"
    param name="ios-package" value="CDVWKWebViewEngine" 
feature

allow-navigation href="" allow-navigation href="http://localhost:8080/"

preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" 

preference name="UseScheme" value="true" preference name="WKPort" value="5667" preference name="WKBind" value="localhost"

plugin name="cordova-plugin-ionic-webview" spec="^2.5.1"
    variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" 
plugin
engine name="android" spec="8.0.0" 
Adza93 commented 5 years ago

@jcesarmobile I have decided to stick with cordova android 7.1.4. It looks like there is some compatibility issue with 8..X.X platform and this version of cordova-webview plugin. I will try to perform same upgrade to cordova android 8.0.0 and see if anything changed.

jcesarmobile commented 5 years ago

There is no issue with cordova-android 8, that’s the version where I tested.

Adza93 commented 5 years ago

Is it maybe because I was on angular 4? I have upgraded to angular 5 after I have stopped with trying platform raise to 8.0.0

Carlosps commented 4 years ago

@Adza93 Chances are the problem is related to the cordova-plugin-crypt-file plugin as mentioned on this issue CORDOVA 7.0.0 net::ERR_FILE_NOT_FOUND