kolbasa/cordova-plugin-apkupdater

Download failed and unknown exception

Closed this issue ยท 9 comments

Hi,
I have problem getting this plugin to work with my application.

Problem:

cordova.plugins.apkupdater.check(
            'http://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update/manifest.json',
            function (oResp) {
                console.log(JSON.stringify(oResp, ' ', 2));
            },function (oResp) {
                console.log(JSON.stringify(oResp, ' ', 2));
            }
        );

I get: "Unknown exception"

cordova.plugins.apkupdater.check(
            'http://10.100.100.60/b/manifest.json',
            function (oResp) {
                console.log(JSON.stringify(oResp, ' ', 2));
            },function (oResp) {
                console.log(JSON.stringify(oResp, ' ', 2));
            }
        );

I get: "Download failed"

Without callback I get:
image

This is what I have on 10.100.100.60/b :
image

On network it doesn't show that it creates a request for the said file regardless of what I try to do.
I read previous issues (closed) and tried with no manifest at the end, tried with other function calls like download, etc. But since it doesn't have a link to pass it aside from check url, I resorted to simply asking.

Cordova 9.0.0 on Android.

No problem, I am happy to receive questions. Especially when the error description is so detailed.

First, this is what the response should look like:

grafik

I can't say exactly what is causing the app error in your case. But it shows me that I should improve the error handling significantly. Currently many errors are simply caught under "Unknown Exception".

If you want to see the complete error, you can do it like this (and I also see that I did not document this correctly :D ).

cordova.plugins.apkupdater.setObserver(
    {
        exception: function (message, stack) {
            console.error(message, stack);
        }
    }
);

await cordova.plugins.apkupdater.check('https://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update');

Then you get the complete stack. And then I can probably say why the connection does not work.
Here is a sample output:

grafik

Hi, thank you for fast reply.
I used it on Android 5.0.1 tablet and got this as response:

image
image

This is from mobile running Android 8.1.0:
image

And success from your code/apk link:
image

I have whitelist, and I did add permission internet in config.xml.
image

My guess is this won't work with ftp since no authentication options are present?

I removed clear text from config.xml and used http (not https), tried again, and got it to install but now I get this message on install (8.1.0):
image
image

On Android 5.0.1 without clear text and with http updated with no problems.

Since it asked for permission to install, it would be nice to configure it to have it (on install) not to confuse users further. And install without prompt would be nice.

Once you add more information about exception I will continue with debugging.

Wow, you are a gold mine for improvements ๐Ÿ˜ƒ

The problem with the missing internet authorization is a good point. I will fix that quickly.

On the subject of FTP, yes, that is currently not planned.
However, password protected access can be controlled directly via the HTTP server.
But I will check if I can add a password restriction.

The url will then look like this:

https://<username>:<password>@raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update

And then the installation problem. This is how it looks like on my end:

grafik

SyntaxError: missing ) after argument list

For me this is an indication that the JavaScript code has a syntax error.
Maybe the problem is your log function. Unfortunately I cannot see it in the example above.

Can you tell me the android + cordova version. I can't reproduce it on my end.

I have found another bug: #11

I post this here because you mentioned Android 5 above.

I'm going to tackle all the little problems this weekend.

This is with log function (just takes 3 params and console logs them).

log = function (a,b,c){console.log(a,b,c)};
cordova.plugins.apkupdater.install();

log = function (a,b,c){console.log(a,b,c)}; cordova.plugins.apkupdater.install(log,log);

image

Tried with cordova.plugins.apkupdater.install(log,log) and without them cordova.plugins.apkupdater.install(). Got error on both (different though)...

On side note you could update readme to include the hint with password and email.
Testing on: Cordova 9.0.0 and Android 8.1.0.

It downloads it (will need to recheck where) but my guess is when it needs to unzip or install it to crash, maybe more permissions are needed?
Also this warning could be a clue?
DevTools failed to load SourceMap: Could not load content for file:///android_asset/www/plugins/code-push/script/acquisition-sdk.js.map: System error: net::ERR_FILE_NOT_FOUND

I can imagine that it is related to this:

grafik

I have to take a closer look at the effects of this.
However, I'll be away for 8 hours, then I have time to look at it. ๐Ÿ‘

I found the problem and fixed it in version 1.2.2. This section overwrote my config changes:

grafik

Here is an example to test the complete process with one copy and paste:

cordova.plugins.apkupdater.setObserver(
    {
        downloadProgress: console.log,
        exception: console.error
    }
);
cordova.plugins.apkupdater.check(
    'https://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update',
    function () {
        cordova.plugins.apkupdater.download(
            function () {
                cordova.plugins.apkupdater.install(console.log, console.error);
            },
            console.error
        );
    },
    console.error
);

It looks like this with Android 8:

android-8

den1a commented

Hi. I couldn't find a solution to update the app for a long time. But I found your plugin. There were problems, but I found the solution on this page. Thank you to the author for the complete answers! I'll give you a star!

Thank you. If problems arise, just let me know.
But this issue can be closed. This is fixed.