Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid service notification error while uploading image #85

Closed
vipul1905 opened this issue Nov 15, 2017 · 9 comments
Closed

invalid service notification error while uploading image #85

vipul1905 opened this issue Nov 15, 2017 · 9 comments

Comments

@vipul1905
Copy link

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.

@tsonevn
Copy link
Contributor

tsonevn commented Nov 27, 2017

Hi @vipul1905,
I tested your scenario on my side while using the attached code, however, I was unable to recreate the reported error. Could you provide sample project, which could be debugged locally. It would also help if you could provide more info about your environment(CLI modules, node, npm) and info about the device or simulator, which is used for testing.

@tsonevn
Copy link
Contributor

tsonevn commented Dec 7, 2017

closing due to inactivity

@tsonevn tsonevn closed this as completed Dec 7, 2017
@NickIliev NickIliev reopened this Jan 24, 2018
@NickIliev NickIliev added the bug label Jan 24, 2018
@NickIliev
Copy link
Contributor

NickIliev commented Jan 24, 2018

Reproduce via this demo application on API levels 26 and 27

Steps to reproduce:

ActivityManager: Process com.google.process.gapps (pid 4283) has died
JS: [object Object]
System.err: android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentV
iew=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0x00000000 groupKey=net.gotev vis=PRIVATE)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     at android.os.Looper.loop(Looper.java:164)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6494)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
ActivityManager: Process org.nativescript.issue99 (pid 22445) has died: fore TOP
ActivityManager: setHasOverlayUi called on unknown pid: 22445
ActivityManager: Start proc com.google.process.gapps for content provider com.google.android.gsf/.gservices.GservicesProvider: pid=717 uid=10007 gids={50007, 9997, 3003, 1028, 1015, 3002, 3001, 10
05, 1007, 3007, 2001, 3006} abi=x86_64
ActivityManager: Process com.android.providers.calendar (pid 5951) has died
ActivityManager: Start proc com.google.android.gms.ui for service com.google.android.gms/.chimera.UiIntentOperationService: pid=22311 uid=10007 gids={50007, 9997, 3003, 1028, 1015, 3002, 3001, 100
5, 1007, 3007, 2001, 3006} abi=x86_64
ActivityManager: Process android.process.media (pid 6423) has died
ActivityManager: Process com.android.deskclock (pid 6662) has died
ActivityManager: Start proc com.android.deskclock for broadcast com.android.deskclock/com.android.alarmclock.DigitalAppWidgetProvider: pid=26953 uid=10022 gids={50022, 9997, 1028} abi=x86_64
ActivityManager: Start proc com.android.calendar for broadcast com.android.calendar/.widget.CalendarAppWidgetService$CalendarFactory: pid=379 uid=10018 gids={50018, 9997, 3003} abi=x86_64
ActivityManager: Process com.google.android.gms.ui (pid 22311) has died
ActivityManager: Start proc com.android.providers.calendar for content provider com.android.providers.calendar/.CalendarProvider2: pid=406 uid=10001 gids={50001, 9997, 3003, 1028, 1015} abi=x86_64
ActivityManager: Slow operation: 1021ms so far, now at getContentProviderImpl: done!
ActivityManager: Start proc com.google.android.gms.ui for service com.google.android.gms/.chimera.UiIntentOperationService: pid=15854 uid=10007 gids={50007, 9997, 3003, 1028, 1015, 3002, 3001, 100
5, 1007, 3007, 2001, 3006} abi=x86_64
ActivityManager: Process com.google.android.gms.unstable (pid 5813) has died
ActivityManager: Start proc com.google.android.gms.unstable for service com.google.android.gms/.droidguard.DroidGuardService: pid=15931 uid=10007 gids={50007, 9997, 3003, 1028, 1015, 3002, 3001, 1
005, 1007, 3007, 2001, 3006} abi=x86_64
ActivityManager: Process com.android.calendar (pid 379) has died
ActivityManager: Unable to start service Intent { cmp=com.google.android.gms/.analytics.service.RefreshEnabledStateService } U=0: not found
ActivityManager: Start proc android.process.media for content provider com.android.providers.downloads/.DownloadProvider: pid=25593 uid=10005 gids={50005, 9997, 1028, 1015, 1023, 1024, 2001, 3003,
 3007} abi=x86_64
ActivityManager: Process com.google.android.gms.ui (pid 15854) has died
ActivityManager: Unable to start service Intent { act=com.google.android.finsky.BIND_PLAY_MODULE_SERVICE pkg=com.android.vending } U=0: not found
ActivityManager: Unbind failed: could not find connection for android.os.BinderProxy@2be8dd9
ActivityManager: Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=25749 uid=10002 gids={50002, 9997, 3003, 1028, 1015} abi=x86_64
ActivityManager: Start proc com.google.android.gms.ui for service com.google.android.gms/.chimera.UiIntentOperationService: pid=25787 uid=10007 gids={50007, 9997, 3003, 1028, 1015, 3002, 3001, 100
5, 1007, 3007, 2001, 3006} abi=x86_64
ActivityManager: Process com.android.providers.calendar (pid 406) has died
ActivityManager: Process com.android.deskclock (pid 26953) has died
ActivityManager: Start proc com.android.deskclock for broadcast com.android.deskclock/com.android.alarmclock.DigitalAppWidgetProvider: pid=29690 uid=10022 gids={50022, 9997, 1028} abi=x86_64
ActivityManager: Process com.google.android.gms.unstable (pid 15931) has died
ActivityManager: Start proc com.google.android.gms.unstable for service com.google.android.gms/.droidguard.DroidGuardService: pid=5172 uid=10007 gids={50007, 9997, 3003, 1028, 1015, 3002, 3001, 10
05, 1007, 3007, 2001, 3006} abi=x86_64
ActivityManager: Process android.process.acore (pid 25749) has die

@LorenDorez
Copy link

I too am having this issue after upgrading to API 27. Any resolution yet?

@LorenDorez
Copy link

for now i just do this on the request object and things are working again

androidDisplayNotificationProgress: false

@mariuspruski
Copy link

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.

@devicrossing
Copy link

@mariuspruski Please can you be more specific about how to resolve this issue

@LorenDorez
Copy link

@b0uda , I resolved this by upgrading to the latest version. This issue should be fixed. Make sure to remove the androidDisplayNotificationProgress: false or set it back to true

@devicrossing
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants