cordova icon indicating copy to clipboard operation
cordova copied to clipboard

java.io.FileNotFoundException: www/favicon.ico

Open vfa-tamhh opened this issue 3 years ago • 3 comments

Bug Report

Problem

What is expected to happen?

No error in logcat.

What does actually happen?

17 14:14:38.288 7757-7757/io.cordova.hellocordova D/PluginManager: postMessage: onPageFinished
2022-05-17 14:14:38.291 7757-7757/io.cordova.hellocordova I/chromium: [INFO:CONSOLE(27)] "Running [email protected]", source: https://localhost/js/index.js (27)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err: java.io.FileNotFoundException: www/favicon.ico
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at android.content.res.AssetManager.nativeOpenAsset(Native Method)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at android.content.res.AssetManager.open(AssetManager.java:897)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at org.apache.cordova.engine.SystemWebViewClient.lambda$new$0$SystemWebViewClient(SystemWebViewClient.java:95)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at org.apache.cordova.engine.-$$Lambda$SystemWebViewClient$sl_w10kTka227lJmCz64A09UKvs.handle(Unknown Source:4)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at androidx.webkit.WebViewAssetLoader.shouldInterceptRequest(WebViewAssetLoader.java:566)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at org.apache.cordova.engine.SystemWebViewClient.shouldInterceptRequest(SystemWebViewClient.java:423)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at h9.a(chromium-TrichromeWebViewGoogle6432.apk-stable-495150734:223)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova W/System.err:     at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative(chromium-TrichromeWebViewGoogle6432.apk-stable-495150734:31)
2022-05-17 14:14:38.293 7757-7900/io.cordova.hellocordova E/SystemWebViewClient: www/favicon.ico

Information

Command or Code

sudo npm install -g cordova
cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add android

Open the project by Android studio. (Android Studio Bumblebee | 2021.1.1 Patch 2) Run app.

Environment, Platform, Device

Android platform. Device: android 12

Version information

cordova -v
11.0.0
cordova platform add android
Using cordova-fetch for cordova-android@^10.1.1
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: io.cordova.hellocordova
	Name: HelloCordova
	Activity: MainActivity
	Android target: android-30
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]

Checklist

  • [x] I searched for existing GitHub issues
  • [x] I updated all Cordova tooling to most recent version
  • [x] I included all the necessary information above

vfa-tamhh avatar May 17 '22 07:05 vfa-tamhh

Cordova doesn't supply a favicon.ico by default. Are you providing one in your www/ folder?

Note that I don't think the favicon is actually used because you don't have any actual browser UI other than the webview rendering itself. But the browser engine still automatically attempts to load favicon.ico regardless.

breautek avatar May 17 '22 13:05 breautek

@breautek I found the solution to resolve this. At this: https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/engine/SystemWebViewClient.java#L423 Change as below:

@Override
    public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
        if (request.getUrl().getPath().equals("/favicon.ico")) {
            return new WebResourceResponse("image/png", null, null);
        } else {
            return this.assetLoader.shouldInterceptRequest(request.getUrl());
        }
    }

After that run the app. No error show in the Logcat. Please check this case. Thank you.

vfa-tamhh avatar May 18 '22 03:05 vfa-tamhh

If the logcat message bothers you, it would be better to simply supply a favicon.ico file.

The suggested code would break actual favicon.ico from working properly. Afaik the favicon.ico isn't actually used or shown, but like I said, the webview engine always requests the favicon.ico when loading the document.

If the favicon.ico is missing, then this is working as intended, not an actual error. The FileNotFoundException would be the expected behaviour in this situation.

breautek avatar May 18 '22 03:05 breautek