英文:
Android Cordova, why can't I access a source image file using this code anymore?
问题
以下是翻译好的部分:
来自我的 Cordova Android 应用(在 Android 13 的 WebView 中运行)的以下 JavaScript 代码:
var redIcon = L.icon({
iconUrl: 'file:///android_asset/www/lib/images/marker-red-small.png',
iconSize: [40, 40]
});
在控制台中触发了以下消息:
不允许加载本地资源:file:///android_asset/www/lib/images/marker-red-small.png
相同的代码在之前的 Android 版本(至少在版本 8 和 9)中可以正常工作。
英文:
The following JavaScript code from my Cordova Android app (running in a webview) on Android 13
var redIcon = L.icon({
iconUrl: 'file:///android_asset/www/lib/images/marker-red-small.png',
iconSize: [40, 40]
});
fails and triggers this message in the console:
Not allowed to load local resource: file:///android_asset/www/lib/images/marker-red-small.png
The same code used to work with previous versions of Android (versions 8 and 9 at least)
答案1
得分: 1
"The scheme, https
, is not configurable by nature.
Please note that this is a breaking change that will cause data associated with the file:// scheme, such as cookies, local storage, local cache, and web-based databases, to be lost. You will need to handle the migration of data. If you are unable to migrate the data at this time, you can revert this setting by setting the AndroidInsecureFileModeEnabled preference flag.
Setting this flag will keep the content on the file:// scheme, which Google reports to be insecure."
see update docs for Cordova-android 10: https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html
I think it's the above preference, not 100% sure. But if not, the update docs should help you further.
英文:
"The scheme, https
, is not configurable by nature.
Please note that this is a breaking change that will cause data associated with the file:// scheme, such as cookies, local storage, local cache, and web-based databases, to be lost. You will need to handle the migration of data. If you are unable to migrate the data at this time, you can revert this setting by setting the AndroidInsecureFileModeEnabled preference flag.
<preference name="AndroidInsecureFileModeEnabled" value="true" />
Setting this flag will keep the content on the file:// scheme, which Google reports to be insecure."
see update docs for Cordova-android 10: https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html
I think it's the above preference, not 100% sure. But if not, the update docs should help you further.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论