forcedotcom / SalesforceMobileSDK-CordovaPlugin

Cordova plugin for the Salesforce Mobile SDK
Other
48 stars 114 forks source link

App crashes on Android 9 (device and emulator) #602

Closed ftcaeappno closed 1 year ago

ftcaeappno commented 1 year ago

We are developing an app using SalesforceMobileSDK-CordovaPlugin and recently found an issue with Android 9. This is the error we are getting: `I/chromium: [INFO:CONSOLE(0)] "Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.", source: file:///android_asset/www/runtime.js (0)

I/chromium: [INFO:CONSOLE(0)] "Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.", source: file:///android_asset/www/polyfills.js (0)

I/chromium: [INFO:CONSOLE(0)] "Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.", source: file:///android_asset/www/main.js (0)`

We did an additional testing: Screen Shot 2022-09-16 at 12 16 35 PM (2)

  1. After updating chrome (webView) version from 79 to 105 didn't resolve the issue.
  2. The app runs fine without this issue after removing SF Cordova plugin.

The error is also in the attached file.

Is there a documented incompatibility between SalesforceMobileSDK-CordovaPlugin and Android 9?

gkotula commented 1 year ago

Hi, did you create your app using forcehybrid? I just used the latest 10.1.1 version of the SDK with forcehybrid and the hybrid_local option to create a new app, installed it on an Android 9 emulator, and I was able to run it just fine.

ftcaeappno commented 1 year ago

Project is build with Ionic, Angular, & Cordova. Not created using forcehybrid.

Ionic:
   Ionic CLI                     : 6.20.1 (.../@ionic/cli/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.0.10
   @angular-devkit/build-angular : 13.2.5
   @angular-devkit/schematics    : 13.2.5
   @angular/cli                  : 13.2.5
   @ionic/angular-toolkit        : 6.1.0

Cordova:
   Cordova CLI       : 10.0.0 (cordova-lib@10.1.0)
   Cordova Platforms : android 9.0.0, ios 6.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 16 other plugins)

Utility:
   cordova-res : 0.15.4
   native-run  : 1.7.0

System:
   Android SDK Tools : 26.1.1 (~/Library/Android/sdk)
   ios-sim           : 8.0.2
   NodeJS            : v16.15.1 (~/node/16.15.1/bin/node)
   npm               : 8.11.0
   OS                : macOS Monterey
   Xcode             : Xcode 13.4.1 Build version 13F100

This issue is caused by angular build step adding with type="module". When type="module" is manually removed this error goes away. This issue is only happening when Salesforce Cordova plugin is present, Without it <script type="module"> is not an issue on android 9

wmathurin commented 1 year ago

If you are loading from file protocol you can’t use modules because file protocol doesn't provide any mime type and modules need to know the mime type. It's being discussed here and there and many other places.

Closing issue since it's not a limitation with Mobile SDK.

sinothomasAppno commented 1 year ago

This project has cordova-plugin-ionic-webview plugin installed.

After some more debugging I think the issue is in SalesforceDroidGapActivity.java L472 where startUrl is hardcoded to file:///android_asset/www/. So even if cordova-plugin-ionic-webview plugin is installed and https:// is available, webview gets redirected to file:///android_asset/www/.

Then, App shows Blank screen with console error Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.", source: file:///android_asset/www/runtime.js