[英]Cordova [Android platform] migration from API 29 to API 30
I'm trying to migrate my mobile app (developed with Cordova and AngularJS for Android and iOS platforms) and I have some issues from API 29 to API 30. In my app I download from a REST service a JSON catalogue with separated pictures (JPG format) that I store in Data Directory (cordova.file.dataDirectory). I'm trying to migrate my mobile app (developed with Cordova and AngularJS for Android and iOS platforms) and I have some issues from API 29 to API 30. In my app I download from a REST service a JSON catalogue with separated pictures (JPG格式)存储在数据目录(cordova.file.dataDirectory)中。 With the app build with API set to 29 the app works fine, downloading pictures and displaying them in an HTML page (updated with AngularJS).
将 API 设置为 29 的应用程序构建应用程序运行正常,下载图片并在 HTML 页面(使用 AngularJS 更新)中显示它们。 But if I try to build it with API set to 30, the app continues to work (it download correctly the json and the jpg files in Data Directory) but without displaying the pictures stored in that directory.
但是,如果我尝试将 API 设置为 30 来构建它,该应用程序将继续运行(它会正确下载 json 和数据目录中的 jpg 文件),但不会显示存储在该目录中的图片。 I also tried to create a new simple mobile app using all the updated component (Cordova 10.0.0, Android platform 10.0.0, plugins, etc.) but I obtain the same behaviour and I cannot resolve this issue.
我还尝试使用所有更新的组件(Cordova 10.0.0、Android 平台 10.0.0、插件等)创建一个新的简单移动应用程序,但我得到了相同的行为,我无法解决这个问题。 Could you help me or have you an idea how to resolve it?
你能帮我或者你知道如何解决它吗?
Cordova v8.1.2 Cordova v8.1.2
Android Platform v8.0.0 Android 平台 v8.0.0
Cordova v10.0.0 Cordova v10.0.0
Android Platform v10.0.0 Android 平台 v10.0.0
cordova-plugin-android-permissions 1.0.2 "Permissions" cordova-plugin-android-permissions 1.0.2“权限”
cordova-plugin-camera 4.1.0 "Camera" cordova-plugin-camera 4.1.0“相机”
cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-compat 1.2.0“兼容”
cordova-plugin-datepicker 0.9.3 "DatePicker" cordova-plugin-datepicker 0.9.3“DatePicker”
cordova-plugin-device 2.0.3 "Device" cordova-plugin-device 2.0.3“设备”
cordova-plugin-dialogs 2.0.2 "Notification" cordova-plugin-dialogs 2.0.2“通知”
cordova-plugin-file 6.0.2 "File" cordova-plugin-file 6.0.2“文件”
cordova-plugin-file-hash 0.4.1 "FileHash" cordova-plugin-file-hash 0.4.1“FileHash”
cordova-plugin-filepath 1.5.8 "cordova-plugin-filepath" cordova-plugin-filepath 1.5.8 “cordova-plugin-filepath”
cordova-plugin-geolocation 4.0.2 "Geolocation" cordova-plugin-geolocation 4.0.2“地理定位”
cordova-plugin-globalization 1.11.0 "Globalization" cordova-plugin-globalization 1.11.0 “全球化”
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser" cordova-plugin-inappbrowser 3.2.0“InAppBrowser”
cordova-plugin.network-information 2.0.2 "Network Information" cordova-plugin.network-information 2.0.2“网络信息”
cordova-plugin-sign-in-with-apple 0.1.2 "cordova-plugin-sign-in-with-apple" cordova-plugin-sign-in-with-apple 0.1.2“cordova-plugin-sign-in-with-apple”
cordova-plugin-splashscreen 5.0.3 "Splashscreen" cordova-plugin-splashscreen 5.0.3“启动画面”
cordova-plugin-statusbar 2.4.3 "StatusBar" cordova-plugin-statusbar 2.4.3“状态栏”
cordova-plugin-whitelist 1.3.4 "Whitelist" cordova-plugin-whitelist 1.3.4 “白名单”
cordova-plugin-wkwebview-engine 1.2.1 "Cordova WKWebView Engine" cordova-plugin-wkwebview-engine 1.2.1 “Cordova WKWebView 引擎”
cordova-plugin-wkwebview-file-xhr 2.1.4 "Cordova WKWebView File XHR Plugin" cordova-plugin-wkwebview-file-xhr 2.1.4 “Cordova WKWebView 文件 XHR 插件”
cordova-sqlite-storage 5.0.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version" cordova-sqlite-storage 5.0.0 《Cordova sqlite 存储插件-cordova-sqlite-storage 插件版》
ionic-plugin-keyboard 2.2.1 "Keyboard" ionic-plugin-keyboard 2.2.1“键盘”
phonegap-plugin-mobile-accessibility 1.0.5-dev "Mobile Accessibility" phonegap-plugin-mobile-accessibility 1.0.5-dev“移动辅助功能”
Try adding to you config尝试添加到您的配置
<preference name="AndroidInsecureFileModeEnabled" value="true" />
The setting Eric suggested might work for you but it's not recommended. Eric 建议的设置可能适合您,但不推荐这样做。 The new cordova-android version uses an API called WebViewAssetLoader to load your app on a proper http(s) scheme instead of file:.
新的 cordova-android 版本使用一个名为 WebViewAssetLoader 的 API 来加载您的应用程序到正确的 http(s) 方案而不是文件:。 I suspect you get CORS issues while downloading your data.
我怀疑您在下载数据时遇到 CORS 问题。
Read more about the WebViewAssetLoader in Cordova: https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html在 Cordova 中阅读有关 WebViewAssetLoader 的更多信息: https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html
A better way is to figure out a proper CORS and to not use the insecure setting.更好的方法是找出一个正确的 CORS 并且不要使用不安全的设置。 You should find plenty of resources about CORS. Reply if you need help.
你应该找到很多关于 CORS 的资源。如果你需要帮助,请回复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.