不允许使用Crosswalk 16+加载本地资源:file:/// android_asset / ....

时间:2016-04-24 17:22:18

标签: android crosswalk xwebview

我有Crosswalk 16.45.421.19的Android项目。

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

我有index.html

&#13;
&#13;
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <base href="/">
    <link rel="icon" href="img/favicon.ico" type="image/x-icon" />
</head>

<body>
    <img src="file:///android_asset/img/logo.png">
    <img src="file:///android_asset/img/preloaderWhite.gif">
    <div id="my-app">Привет!!!!</div>
</body>

</html>
&#13;
&#13;
&#13;

xWalkWebView.load("file:///android_asset/index.html", null);  //All works!

当此文件在服务器上时:

xWalkWebView.load("http://192.168.0.102/", null); //Get index.html, but images don't load.

并且:

Not allowed to load local resource: file:///android_asset/img/logo.png"

1 个答案:

答案 0 :(得分:-1)

您好,请查看CSP内容安全策略https://developer.mozilla.org/en/docs/Web/Security/CSP,我相信这是您的主题