Closed CloudedDragon closed 8 years ago
My device is Android 4.1.1 get NullPointerException , but when I use Android 4.4 device, and it work fine
dependencies {
compile 'com.mani:ThinDownloadManager:1.2.1'
}
I ran into this too. I have a fix, and will create a pull request shortly.
Edit: Pull Request
I have updated to 'com.mani:ThinDownloadManager:1.2.2'. Actually DownloadDispatcher is trying to write data on destination. But the destination file was not available in that location, while It was trying to write streamed data. My suggestion is destination should be validated before write data! @harinair - Can you please have a look on this issue ?
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[], int, int)' on a null object reference
at com.thin.downloadmanager.DownloadDispatcher.writeDataToDestination(DownloadDispatcher.java:315)
at com.thin.downloadmanager.DownloadDispatcher.transferData(DownloadDispatcher.java:295)
at com.thin.downloadmanager.DownloadDispatcher.transferData(DownloadDispatcher.java:238)
at com.thin.downloadmanager.DownloadDispatcher.executeDownload(DownloadDispatcher.java:142)
at com.thin.downloadmanager.DownloadDispatcher.run(DownloadDispatcher.java:81)
My pull request is still pending approval. It is a very simple solution. My fork has it applied to master. I am currently weighing the benefits of maintaining the fork in light of my likely work toward new features. No promises though.
@PrimeKang I could not see any pull requests against this repo? Did you submit one? I noticed that many PR take a lot of time to get approved.
@CloudedDragon @praveen2gemini Please update to the latest version 1.2.3
@PrimeKang Appreciate your findings.
@smanikandan14 Fix doesn't resolve our issue. Our Scenario is like this. We are deleting the created file path in a separate thread whenever the user cancels the download from UI and by this time the download manager is trying to write to the file which is already deleted. This leads to the Null pointer exception crash. Why we followed this approach is because ThinDownload manager sets the cancel flag to true and doesn't stop the download(Thread) immediately. Also it throws the cancelled error only after few seconds and we cannot delay the UI updation till we get the download cancelled message.
This case is handled now safely. DownloadManager.ERROR_FILE_ERROR
will be given in the callback onDownloadFailed
if the destination file is not found during download. Please try version 1.2.4
@praveen2gemini Closing this if there are no concerns.
@smanikandan14 It works! Thanks.
@praveen2gemini @smanikandan14 Thank you for taking care of this.
03-06 03:51:24.442 15594-15754/? E/AndroidRuntime: FATAL EXCEPTION: Thread-61117 java.lang.NullPointerException at com.thin.downloadmanager.DownloadDispatcher.writeDataToDestination(DownloadDispatcher.java:315) at com.thin.downloadmanager.DownloadDispatcher.transferData(DownloadDispatcher.java:295) at com.thin.downloadmanager.DownloadDispatcher.transferData(DownloadDispatcher.java:238) at com.thin.downloadmanager.DownloadDispatcher.executeDownload(DownloadDispatcher.java:142) at com.thin.downloadmanager.DownloadDispatcher.run(DownloadDispatcher.java:81)