NPE at Android 8 with empty UploadNotificationConfig
See original GitHub issueWhat 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:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top 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 >
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
@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.
@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?