Home > Software design >  Cordova [Android platform] migration from API 29 to API 30
Cordova [Android platform] migration from API 29 to API 30

Time:10-09

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). 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). 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. 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. Could you help me or have you an idea how to resolve it?

Info App build with API 29

Cordova v8.1.2
Android Platform v8.0.0

Info App build with API 30

Cordova v10.0.0
Android Platform v10.0.0

Plugins List

cordova-plugin-android-permissions 1.0.2 "Permissions"
cordova-plugin-camera 4.1.0 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-datepicker 0.9.3 "DatePicker"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-file-hash 0.4.1 "FileHash"
cordova-plugin-filepath 1.5.8 "cordova-plugin-filepath"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-sign-in-with-apple 0.1.2 "cordova-plugin-sign-in-with-apple"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-wkwebview-engine 1.2.1 "Cordova WKWebView Engine"
cordova-plugin-wkwebview-file-xhr 2.1.4 "Cordova WKWebView File XHR Plugin"
cordova-sqlite-storage 5.0.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-mobile-accessibility 1.0.5-dev "Mobile Accessibility"

CodePudding user response:

Try adding to you config

 <preference name="AndroidInsecureFileModeEnabled" value="true" />

CodePudding user response:

The setting Eric suggested might work for you but it's not recommended. The new cordova-android version uses an API called WebViewAssetLoader to load your app on a proper http(s) scheme instead of file:. I suspect you get CORS issues while downloading your data.

A better way is to figure out a proper CORS and to not use the insecure setting. You should find plenty of resources about CORS. Reply if you need help.

  • Related