You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Kerri Shotts (JIRA)" <ji...@apache.org> on 2017/06/13 20:10:00 UTC

[jira] [Commented] (CB-12894) Opening a Local File - breaking on cordova.js

    [ https://issues.apache.org/jira/browse/CB-12894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16048345#comment-16048345 ] 

Kerri Shotts commented on CB-12894:
-----------------------------------

What version of {{cordova-android}} and the file plugin are you using? Does anything show in the device log when this error occurs ({{adb logcat}})?

> 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: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org