[
https://issues.apache.org/jira/browse/CB-12894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16052085#comment-16052085
]
Joe Bowser commented on CB-12894:
---------------------------------
This is a bug with the FileOpener2 plugin, which is a third party plugin. The
call is correctly coming to the the open call in the plugin, but for some
reason where FileOpener2 calls getUriForFile, it fails. I would check with the
plugin author, since it seems that Cordova is correctly sending the call to the
plugin given the stack trace.
> Opening a Local File - breaking on cordova.js
> ---------------------------------------------
>
> Key: CB-12894
> URL: https://issues.apache.org/jira/browse/CB-12894
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-android
> Environment: DevExtreme SPA Application using Cordova
> Reporter: Kyle Slack
>
> We have an application that has a self updating feature, we do not host in
> the Google Play Store, however, we host it for our users. We have had success
> with previous versions of our application, but recently on newer devices
> running Android 6.0 or higher our users are running into an error when trying
> to open the downloaded .apk file that should provide our users with an
> updated version of the app prompted for installation. On Android 6.0 or lower
> everything is working perfectly fine with the following code. Lastly, we were
> able to debug this to the point where we can see the file is actually
> downloading fine, and only the call to open the file throws an exception. We
> were able to debug down into the cordova.js file and found that there was an
> exception occurring when the fileOpener2 plugin performs it's open()
> callback, but seems like this is related to Cordova and not anything to do
> with the fileOpener2, we have already discussed this with the developer.
> Test Device Info: Motorola Turbo 2 / Android 7.0
> Exception Msg: 230 F09 FileOpener21362683899 sAttempt to invoke virtual
> method 'android.content.res.XmlResourceParser
> //android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager,
> java.lang.String)' on a null object reference
> Code:
> {code}
> // we need to access LocalFileSystem
> window.requestFileSystem(LocalFileSystem.PERSISTENT, 5 * 1024 * 1024,
> function (fs) {
> //Show user that download is occurring
> $("#toast").dxToast({
> message: "Downloading please wait..",
> type: "warning",
> visible: true,
> displayTime: 20000
> });
> // we will save file in .. Download/OURAPPNAME.apk
> var filePath = cordova.file.externalRootDirectory + '/Download/'
> + "OURAPPNAME.apk";
> var fileTransfer = new FileTransfer();
> var uri = encodeURI(appDownloadURL);
> fileTransfer.download(uri, filePath, function (entry) {
> //Show user that download is occurring/show user install is
> about to happen
> $("#toast").dxToast({
> message: "Download complete! Launching...",
> type: "success",
> visible: true,
> displayTime: 2000
> });
> ////Use pwlin's fileOpener2 plugin to let the system open the
> .apk
> cordova.plugins.fileOpener2.open(
> entry.toURL(),
> 'application/vnd.android.package-archive',
> {
> error: function (e) {
> window.open(appDownloadURL, "_system");
> },
> success: function () { console.log('file opened
> successfully'); }
> }
> );
> },
> function (error) {
> //Show user that download had an error
> $("#toast").dxToast({
> message: error.message,
> type: "error",
> displayTime: 5000
> });
> },
> false);
> })
> {code}
> Problem File: cordova.js
> THIS IS ALL NOT OUR CODE, BUT 'CORDOVA' CODE
> {code}
> function androidExec(success, fail, service, action, args) {
> // argsJson -
> "["file:///storage/emulated/0/download/OURAPPNAME.apk","application/vnd.android.package-archive"]"
> //callbackId - FileOpener21362683899
> //action - open
> //service FileOpener2
> //bridgesecret - 1334209170
> var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action,
> callbackId, argsJson);
> // If argsJson was received by Java as null, try again with the PROMPT
> bridge mode.
> // This happens in rare circumstances, such as when certain Unicode
> characters are passed over the bridge on a Galaxy S2. See CB-2666.
> if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "@Null
> arguments.") {
> androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
> androidExec(success, fail, service, action, args);
> androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
> } else if (msgs) {
> messagesFromNative.push(msgs);
> // Always process async to avoid exceptions messing up stack.
> nextTick(processMessages);
> }
> // msgs = "230 F09 FileOpener21362683899 sAttempt to invoke virtual method
> 'android.content.res.XmlResourceParser
> //android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager,
> java.lang.String)' on a null object reference"
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]