question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

invalid service notification error while uploading image

See original GitHub issue

I am trying to single image. But I get the following error

An uncaught Exception occurred on "main" thread.
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0x00000000 groupKey=net.gotev vis=PRIVATE)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

This is the upload function:

 displayImage(){
        var documents = fs.knownFolders.temp();

        documents.getEntities()
        .then((entities)=>{
            // entities is array with the document's files and folders.
            entities.forEach((entity)=>{
                console.log(entity);
                console.log(entity.path);
                
                let token = appSettings.getString("token");
                console.log(token);
                if (token != ''){

                    var request = {
                        url:  url
                        method: "POST",
                        headers: {
                            "Content-Type": "application/octet-stream",
                            "File-Name": entity.path,
                            "Authorization": "Bearer " + token  
                        },
                        description: "{ 'uploading': 'bigpig.jpg' }"
                    };
                    
                    var task = session.uploadFile(entity.path, request);
                    
                    task.on("progress", this.logEvent);
                    task.on("error", this.logEvent);
                    task.on("complete", this.logEvent);
                    
                   
              }
            });
        }, function (error) {
            // Failed to obtain folder's contents.
            // globalConsole.error(error.message);
        });

the entity path is " /data/user/0/org.testApp.testApp/cache/savedImage1510757546373.jpg". I tried to save the image to the temp folder of the emulator and find the file and upload to the server.

Could anyone tell me what is missing? and what this error means? Any help would be much appreciated. Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mariuspruskicommented, Mar 7, 2018

This is still the case with version 3.2.1 when using androidDisplayNotificationProgress: true When setting this property to false, we get a different exception, namely:

JS: ERROR Error: Uncaught (in promise): Error: java.lang.IllegalArgumentException: Android Oreo requires a notification configuration for the service to run. https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)
JS:     net.gotev.uploadservice.UploadRequest.startUpload(UploadRequest.java:72)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)

As far as I can see, this library in its newest version ALWAYS needs a notificationConfig, otherwise it will throw this exception.

We will stay on version 3.2.0 with notifications disabled, as this seems to be the only working way on Android Oreo.

0reactions
devicrossingcommented, Apr 17, 2018

@mariuspruski thx for your quick reply , updated all modules and still have the same error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Gotev Upload Image Bad notification for ...
I've trying to check on gotev github, but I found kotlin tutorial only. how to use gotev image upload in my Upload.java or...
Read more >
AdminApp: "Invalid file" error when uploading image
When a new image is uploaded, an error with message "Invalid file" is observed.
Read more >
Error while uploading image in lightning community
I am trying to upload image in lighnint community and trying to change logo of community but i am getting error when i...
Read more >
Invalid Object Error Message - Breeze Church Management
Please try to re-upload the image in jpeg format, assure that the image is in full-color, and right-side up. Also, assure that the...
Read more >
Fix error messages with Uploaded ads - Google Ads Help
When uploading creatives in Google Ads, you may receive an error message. In most situations, the problem can be fixed by altering your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found