File Protocol: FILE_URI in android doesn't display image

I’m trying to display an image taken with camera.
But I have problems with FILE_URI destination type

Latest documentation of Ionic 4 explains the correct way to update the file protocol: from “file:///xxxxx/xxxx…” to “/xxxxx/xxxx…”

But android doesn’t display the image.

I need the image file because I need to load it in my server.
Do you have some tricks?
Thanks in advance

1 Like

I have the same issue in an ionic-v3 build and <img src="assets/imgs/logo.png"> and <div style="background-image: url('assets/imgs/logo.png')"></div>"-stuff. Also with background-images defined in the stylesheet.

Interestingly enough: similar stuff does not happen when creating a new project from the latest CLI version (4.1.1). My ionic-v3 project was created a few months ago with an older version.

Debugging showed that the newer version has a file named $root/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/, with other Ionic...-files there.
The older version seems to simply use this: $root/platforms/android/CordovaLib/src/org/apache/cordova/

In the IonicWebViewEngine there is e.g. this piece of code:

localServer = new WebViewLocalServer(cordova.getActivity(), "localhost:" + port, true, parser);
WebViewLocalServer.AssetHostingDetails ahd = localServer.hostAssets("www");

I cannot find a good equivalent in the old version as of yet. I’m still debugging my way through, though.

Any help as to why the older ionic-v3-version does not translate assets from using the file protocol to localhost correctly is appreciated.

@luigimassa Did you figure something out?

I wish there would have been a different way, but after lots of playing around and debugging, I’m carefully migrating my app to v4 beta. All tests succeed with that version. The new seems to be much better and stabler in this regard.

I fully believe that at some point the “old” Ionic v3 worked perfectly the way it was. I imagine some of the many dependencies outpaced each other (maybe @ionic-cli? Or cordova-android? @ionic-native/core? Or the now seemingly obsolete @ionic/app-scripts?) and the tests just didn’t catch this particular dependency configuration issue.