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) #609

Closed ftcaeappno closed 1 year ago

ftcaeappno commented 1 year ago

Creating this ticket since the original (602) was closed. https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin/issues/602

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)`

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

wmathurin commented 1 year ago

The code you pointed to is in loadLocalStartPage(). There is also a loadRemoteStartPage() method which loads the start page read in the bootconfig without prepending anything. To have that method used, you need to set isLocal in your bootconfig file to false.

ftcaeappno commented 1 year ago

@wmathurin thank you for the prompt response. We'll check and let you know.

sinothomasAppno commented 1 year ago

Thanks @wmathurin https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin/issues/609#issuecomment-1284577548 fixed the issue.

brandonpage commented 1 year ago

Thanks for confirming the issue is fixed!

sinothomasAppno commented 1 year ago

@wmathurin Solution in https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin/issues/609#issuecomment-1284577548 breaks the auth flow when user is opening the app after logged in once. I believe this is because changing isLocal from true to false has other impacts.

Found working solution in PR #605.

@wmathurin any ideas why this PR was closed without merge. I think without changes in this PR this plugin doesnot work with cordova-android:10.x.x. Unless a fix for this already added in another PR.