apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

`ErrorURL` preference is not working #1690

Closed homerlex closed 3 months ago

homerlex commented 3 months ago

Bug Report

Problem

ErrorURL preference is not working

What is expected to happen?

When there is an error loading a remote page to the webview we expect the error page to load

What does actually happen?

The error page doesn't load. We get a screen that says Webpage not available net::ERROR_CONNECTION_REFUSED

Information

We have an error.html page.
We have the following in our config.xml: <preference name="ErrorURL" value="file:///android_asset/www/error.html" />

It used to work that when the app could not load a remote page to the webview this error page would be rendered. We don't know when this broke but assume it was when we upgraded the cordova Android platform.

I don't see any documentation the usage of ErrorURL has changed. Is there a known issue or are we no longer using it properly?

I also tried this: <preference name="ErrorURL" value="error.html" />

Command or Code

<preference name="ErrorURL" value="file:///android_asset/www/error.html" /> in config.xml

Environment, Platform, Device

Cordova Android Platform: android 12.0.1 Device running Android 13

Version information

Cordova Android Platform: android 12.0.1 cordova --version - 12.0.0 (cordova-lib@12.0.1) Compiled on Windows 12 No Plugins - tested with clean HelloWorld project

Checklist

homerlex commented 3 months ago

I figured it out. I needed to add: <allow-navigation href="file:///android_asset/www/error.html" />

I guess this was not needed in Android Platform 9.x

jablka commented 3 months ago

I have also trouble setting this up :( while adding <allow-navigation href="file:///android_asset/www/error.html" /> is a good workaround, however after displaying my custom ErrPage I cannot navigate back!

After pushing back button (the native android navigation button) the app simply exits (or more correctly: I am returned back to android launcher). And when clicking the app icon again, it is still stucked on my ErrPage.

Any suggestions?