Android 9 wont build [FORGE WebView error] net::ERR_CONNECTION_REFUSED


#1

When I try and build using ‘Android’ on a android 9 device I get this message

[FORGE WebView error] net::ERR_CONNECTION_REFUSED

The splash screen does not go away, it appears it does not even load up the webview at all. I thought it might be httpd so I add a cert to that and its still not working.

This is with the latest Forge build

I should add that I also selected the ‘allowcleartext’ option under flag but that does not seem to work…

** Update **
It appears that something with the 2.7.7 and 2.7.6 breaks the webview with Android… Not sure what going on with it, however if I use 2.7.6 and build to CrossWalk it work, but building to CrossWalk with 2.7 does not appear to work…

Also, just to note, I do have a feeling it may be linked to the HTTD module, because that is the URL its trying to hit. I noticed if I changed it to localhost and tried to use a self signed cert it would then give me a different error, complaining about the cert, so maybe that is root cause?


Window.refresh opens seperate browser window httpd
#2

A few notes:

  • Crosswalk is no longer officially supported. We’ll keep the target active due to popular demand but everyone is on their own :slight_smile:
  • As of Android 9, if you’re using the httpd module then https:// with a self-signed certificate is the only supported way forward.

Things to check:

  • Did you include https://localhost/* in your trusted_urls configuration?
  • If you specified a url in the httpd module configuration, did you remember to also specify a port?
  • If you specified a port, did you update the url to reflect that port? (i.e. if you set the port to 31337 then url would be https://localhost:31337/src/index.html)

This works for me with a self-signed certificate:

{
    "config_version": "4",
    "name": "20190405-proxim0",
    "author": "antoine@trigger.io",
    "version": "0.1",
    "platform_version": "v2.7.7",
    "description": "An empty app created by default",
    "core": {
        "general": {
            "logging": {
                "level": "DEBUG"
            },
            "reload": true,
            "trusted_urls": [
                "https://localhost/*"
            ]
        },
        "ios": {
            "webview": "WKWebView"
        }

    },
    "modules": {
        "httpd": {
            "config": {
                "port": 31337,
                "url": "https://localhost:31337/src/index.html",
                "certificate_path": "localhost.p12",
                "certificate_password": "insecure"
            },
            "version": "1.4"
        }
    }
}

You can grab the certificate I used here: localhost.txt (2.3 KB)

Just rename it to localhost.p12 and drop it in your app’s src/ directory.

If you’re still having issues can you please:

  1. Provide some info on the hardware you’re testing on
  2. Attach your src/config.json
  3. Attach the output from: forge run android -v
  4. Attach the output from: adb logcat

Some build errors
#3

Ahh Ok, I think I figured out what the issue was, so, first off yes Antonie we all know CrossWalk is no longer supported :smiley: Sorry, I know you have to say it but we loved you CrossWalk :frowning:

Anyhow when I was trying this out I had a selfsigned cert, port set etc however the URL I had was just https://localhost I did not add on src/index.html

I did that an now it works :smiley:

Maybe add a link to this post on the docs or maybe update them to reflect the setup. Right now they are a bit thin on it because it says to key the defaults for URL but when you do it used the IP vs localhost.

Also, not sure if it matters much because I know a lot just edit via config.json but the port option does not show on the web-view

Anyhow, thanks again Antonie!