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.

NPE at Android 8 with empty UploadNotificationConfig

See original GitHub issue

What did you expect?

I am setting up the Upload Task with empty UploadNotificationConfig, because I don’t need any notifications in my app.

What happened instead?

NPE crash:

UploadService - Error while instantiating new task
                                    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String net.gotev.uploadservice.UploadNotificationConfig.getNotificationChannelId()' on a null object reference
                                        at net.gotev.uploadservice.UploadTask.init(UploadTask.java:126)
                                        at net.gotev.uploadservice.HttpUploadTask.init(HttpUploadTask.java:37)
                                        at net.gotev.uploadservice.MultipartUploadTask.init(MultipartUploadTask.java:38)
                                        at net.gotev.uploadservice.UploadService.getTask(UploadService.java:351)
                                        at net.gotev.uploadservice.UploadService.onStartCommand(UploadService.java:256)

Version info

  • Android Upload Service version: 3.4
  • Android version and API version: 26
  • HTTP stack (e.g. HurlStack or OkHttpStack): OkHttpStack

Request code:

new MultipartUploadRequest(getBaseContext(), url)
                         .setNotificationConfig(null)
                        .startUpload();

Where have you added the request code?

Service

Additional info

I’ve checked the code, there’s everywhere checks like if (params.notificationConfig == null) return; However, in init method it is missing, thus causing the NPE. Solution is quite simple - add the null check.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jbekascommented, Nov 16, 2017

@gotev In my app, the progress indicator and cancel capability are built into the UI. So yes, there are occasions where the developer may want to set UploadNotificationConfig to null. This works fine for Android prior to SDK 26.

0reactions
gotevcommented, Nov 19, 2017

@jbekas @guerrillalg @darekxan 3.4.1 released!

Also, since some of you told me you’re using custom notification systems, what could Android Upload Service do to ease your job or make your code better?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upload image with android-upload-service - Stack Overflow
String url = " http://server.yourserver.com/v1/example"; try { String uploadId = UUID.randomUUID().toString(); //Creating a multi part ...
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