titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

Android Webview android:targetSdkVersion=30+ access local files default changed

Open markive opened this issue 4 years ago • 12 comments
trafficstars

With Android SDK Version 30+ by default a webview will not have access to local assets like images accessed through file://.

This is therefore a breaking change since previously the default was for this setting to be true.

Android documentation of the change: https://developer.android.com/reference/android/webkit/WebSettings#setAllowFileAccess(boolean)

Stackoverflow dealing with the problem natively: https://stackoverflow.com/a/63846853/181197

I will submit a PR so that this becomes a property.

markive avatar Nov 18 '21 01:11 markive

To have the hyperloop workaround here too if someone finds this issue:

const WebView = require('android.webkit.WebView');
var webView = new WebView($.www); // convert your WebView to a native WebView
console.log(webView.getSettings().getAllowFileAccess()); // false
webView.getSettings().setAllowFileAccess(true);
console.log(webView.getSettings().getAllowFileAccess()); // true

m1ga avatar Nov 19 '21 15:11 m1ga

Please see new PR where I have implemented setAllowFileAccess / getAllowFileAccess as a full Android property. Thanks!

markive avatar Jan 04 '22 09:01 markive

Is there any progress here?

Xlinx64 avatar Mar 08 '22 09:03 Xlinx64

Is there any progress here?

akinsoftyazilim42 avatar Jul 07 '22 12:07 akinsoftyazilim42

Hyperloop doesn’t work in my app so I had to build a custom sdk. That is not optimal for production. But I had no other choice.

Xlinx64 avatar Jul 07 '22 12:07 Xlinx64

Hyperloop doesn’t work in my app so I had to build a custom sdk. That is not optimal for production. But I had no other choice.

How were you to build a custom sdk. I don't know this. are There help videos or documents?

akinsoftyazilim42 avatar Jul 07 '22 13:07 akinsoftyazilim42

There is just this section here on how to build locally: https://github.com/tidev/titanium_mobile#building-locally But you need to clone the repo and implement this change: https://github.com/tidev/titanium_mobile/pull/13189/files

Xlinx64 avatar Jul 07 '22 13:07 Xlinx64

I've triggered the build again. If it runs successfully you can also download the artifact from there. Otherwise as @Xlinx64 showed. Check https://stackoverflow.com/a/30584951/5193915 how to get a PR.

@Xlinx64 just curious: why didn't hyperloop work for you?

I'll also check the PR and see if it can be merged soon

m1ga avatar Jul 07 '22 13:07 m1ga

@m1ga I used hyperloop for some time but after the update to titanium 10 the webview didnt load anymore. I couldnt really figure out why the hyperloop broke it.

Xlinx64 avatar Jul 07 '22 13:07 Xlinx64

A last question: You've added setAllowFileAccess to the SDK, right? One concern in the PR was that Google will eventually flag the app as insecure. Do you have your app in store and did Google complain about it?

m1ga avatar Jul 07 '22 13:07 m1ga

@akinsoftyazilim42 you can download a build from https://github.com/tidev/titanium_mobile/actions/runs/2629857662 scroll down and download the zip

m1ga avatar Jul 07 '22 14:07 m1ga

I didnt have a problem with this. I already updated the app 2 times in the playstore and there where no complaints from google.

Xlinx64 avatar Jul 07 '22 14:07 Xlinx64