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"
This is what I have on 10.100.100.60/b :
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:
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:
Hi, thank you for fast reply.
I used it on Android 5.0.1 tablet and got this as response:
This is from mobile running Android 8.1.0:
And success from your code/apk link:
I have whitelist, and I did add permission internet in config.xml.
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):
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:
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);
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 found the problem and fixed it in version 1.2.2. This section overwrote my config changes:
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:
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.