cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle Slack (JIRA)" <>
Subject [jira] [Created] (CB-12894) Opening a Local File - breaking on cordova.js
Date Wed, 07 Jun 2017 17:33:18 GMT
Kyle Slack created CB-12894:

             Summary: Opening a Local File - breaking on cordova.js
                 Key: CB-12894
             Project: Apache Cordova
          Issue Type: Bug
         Environment: DevExtreme SPA Application using Cordova
            Reporter: Kyle Slack
            Priority: Critical

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
//, java.lang.String)'
on a null object reference

// we need to access LocalFileSystem
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 5 * 1024 * 1024, function (fs)
            //Show user that download is occurring
                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);

  , filePath, function (entry) {
                //Show user that download is occurring/show user install is about to happen
                    message: "Download complete! Launching...",
                    type: "success",
                    visible: true,
                    displayTime: 2000

                ////Use pwlin's fileOpener2 plugin to let the system open the .apk
                        error: function (e) {
                  , "_system");
                        success: function () { console.log('file opened successfully'); }
            function (error) {
                //Show user that download had an error
                    message: error.message,
                    type: "error",
                    displayTime: 5000

Problem File: cordova.js

function androidExec(success, fail, service, action, args) {

// argsJson - "["file:///storage/emulated/0/download/OURAPPNAME.apk","application/"]"
//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(success, fail, service, action, args);
    } else if (msgs) {
        // Always process async to avoid exceptions messing up stack.

// msgs = "230 F09 FileOpener21362683899 sAttempt to invoke virtual method 'android.content.res.XmlResourceParser
//, java.lang.String)'
on a null object reference"

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message