Does not work with Android 8.0.0?
See original GitHub issueHello,
I have a Sony Xperia X with Android 8.0.0 and I just get an error with I call the function uploadFile()
. The code works fine on Samsung S6 Android 7.0 and on iOS.
Note that no request ever arrives to the server so it’s not a network error. It does not work on http nor https server.
Here is the portion of code if it helps
import * as bghttpModule from 'nativescript-background-http';
constructor(
...
) {
...
this.session = bghttpModule.session('image-upload-bg-http');
}
private sendImages(fileUri): Q.Promise<any> {
const defer = Q.defer();
const imageName = this.extractImageName(fileUri);
const request = {
url: ... [[ some rest api url ]],
method: 'PATCH',
headers: {
'Content-Type': 'application/octet-stream',
'File-Name': imageName,
'Content-Disposition': `attachment; filename=${imageName}`,
Authorization: ... [[anonymized]],
},
description: "{ 'uploading': " + imageName + ' }',
};
const task = this.session.uploadFile(fileUri, request);
task.on('progress', logEvent);
task.on('error', err => {
defer.reject(err);
});
task.on('complete', () => {
defer.resolve();
});
function logEvent(e) {
console.log('currentBytes: ' + e.currentBytes);
console.log('totalBytes: ' + e.totalBytes);
console.log('eventName: ' + e.eventName);
}
return defer.promise;
}
Here is the error log I have.
JS: === dump(): dumping members ===
JS: {
JS: "eventName": "error",
JS: "object": {
JS: "_observers": {
JS: "progress": [
JS: {
JS: "callback": "callback()function logEvent(e) {\n console.log('currentBytes: ' + e.currentBytes);\n console.log('totalBytes: ' + e.totalBytes);\n console.log('eventName: ' + e.eventName);\n }"
JS: }
JS: ],
JS: "error": [
JS: {
JS: "callback": "callback()function (err) {\n defer.reject(err);\n }"
JS: }
JS: ],
JS: "complete": [
JS: {
JS: "callback": "callback()function () {\n defer.resolve();\n }"
JS: }
JS: ]
JS: },
JS: "_session": {
JS: "_id": "image-upload-bg-http"
JS: },
JS: "_id": "image-upload-bg-http{1}",
JS: "_description": "{ 'uploading': random-avatar-2.png }",
JS: "_upload": 0,
JS: "_totalUpload": 1,
JS: "_status": "error"
JS: },
JS: "error": null
JS: }
JS: === dump(): dumping function and properties names ===
JS: === dump(): finished ===
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Android 8.0 Oreo problems list, Dec 2022 - Product Reviews Net
Android 8.0 Oreo problems include: – Installation problem with a 'Couldn't Update' message popping up on screen. – Battery life drain complaints on...
Read more >Android 8.0 Compatibility Definition
This document enumerates the requirements that must be met in order for devices to be compatible with Android 8.0. The use of “MUST”,...
Read more >Is Android 8.0 still supported? - Quora
No, it is unsupported as far as apps are concerned most still run, but Google says it is unsupported, and it no longer...
Read more >10 Common Android 8.1 Oreo Problems & How to Fix Them
If your Nexus or Pixel is randomly rebooting itself, here are a few remedies to try before contacting Google for a potential replacement...
Read more >Android 8.0 Known Issue: WebView issue on work profile
Android devices with work profiles running Android Oreo (Android 8.0) may be affected by the following known issue. Fully managed devices remain unaffected....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It looks like for Android 8.0 we have to create a NotificationChannel.
The code to do it in Java is located at https://github.com/gotev/android-upload-service/blob/master/uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java in the function init()
But it looks like this part is never called.
A quick fix is to modify in
background-http-android.ts
There is a missing check for the API version but I don’t know if a real fix in a pull request would not be better.
I confirm that everything is working well on my side. Do not hesitate to force the last version by updating your
package.json
, removingnode_modules
andplatforms
and do a clean run.