Search code examples
androidhtmlgoogle-chromelocalopera

Android: open a local HTML file stopped working after an update


I have a very specific question for you today.

I am a bioenergeticist and with my basic skills I developped a tool that helps me create files for my patients.

I use it with a Lenovo tablet TB-X306F, originally Android 10 now 11. My tool is a short HTML file with a CSS and 3 pictures. There is a canvas that lets me draw arrows and circles around human body parts (background pic). There are also a few textareas that lets me type the client's name, his symptoms and so on. When I'm done I print to a PDF file and that gives me a nice sheet for each client.

In my office there is no internet access, so the html file, the css and the pictures need to be stored locally.

Until now I used Opera and the 'file:///storage/emulated/0/Download/yyyyy.html' trick and it did great. Until android 11 came. I guess the restrictions must have tightened because since last week, right after that update and still with Opera's authorizations maxed out, I get the error 'ERR_ACCESS_DENIED'.

I can't seem to find a way around it that completely works.

  • I tried Chrome, Firefox, Opera, same error.

  • I tried to store the files in a SD Card, same error.

  • I tried to store the html file as an Offline page in Chrome and Opera, it works a few times then either the page disappears or the canvas won't be showed anymore.

  • I tried installing Simplehttpserver app, but as I'm moving my tablet home to answer emails, then in the office where there is no internet, the server randomly changes ip, turns off then on...

  • I tried uploading the files to a storage website, then downloaded the files from Chrome. This time it opened the HTML file but the pictures don't appear.

  • The Webview that I tried didn't have the option to print, and this is mandatory for me.

  • Rolling back to android 10 would be a short term solution, since I will have to change the tablet someday anyway.

I'm getting out of ideas. Any help would be greatly appreciated.

Thanks, Olivier


Solution

  • My suggestion is to add the following line of code to your AndroidManifest.xml:

    android:usesCleartextTraffic="true"

    After that reinstall the app. Now everything should work fine. Cheers