tonyofrancis / Fetch

The best file downloader library for Android
https://www.meta.stackoverflow.com/tags/fetch2
Apache License 2.0
1.63k stars 328 forks source link

This fetch instance has been closed. Create a new instance using the builder #659

Open wahyurama-creator opened 1 year ago

wahyurama-creator commented 1 year ago

When i resume my activity, error is showing "com.tonyodev.fetch2.exception.FetchException: This fetch instance has been closed. Create a new instance using the builder", how to fix it?

Umesh-Patidar commented 11 months ago

I am getting same crash. Could you please check this.

private fun downloadMedia(filePath: String) { val fetchConfiguration = FetchConfiguration.Builder(this) .setDownloadConcurrentLimit(5) .setProgressReportingInterval(500) .build() Fetch.Impl.setDefaultInstanceConfiguration(fetchConfiguration) fetch = Fetch.Impl.getDefaultInstance() val mediaRequest = url?.let { Request(it, filePath) } mediaRequest?.let { request-> request.priority = Priority.HIGH request.networkType = NetworkType.ALL // fetch = if (fetch == null || fetch?.isClosed == true) FoneAppApplication.instance.getFetch() else fetch fetch?.enqueue(request, { updatedRequest: Request? -> Timber.d("Media File enqueue successfully!! ${updatedRequest?.id}") }) { error: Error? -> Timber.d("Media File is not enqueue!! ${error?.name}") } }

com.tonyodev.fetch2.exception.FetchException: This fetch instance has been closed. Create a new instance using the builder. com.tonyodev.fetch2.fetch.FetchImpl.throwExceptionIfClosed(FetchImpl.kt:1226) com.tonyodev.fetch2.fetch.FetchImpl.enqueueRequest(FetchImpl.kt:97) com.tonyodev.fetch2.fetch.FetchImpl.enqueue(FetchImpl.kt:69)

tech-ajit-mob commented 10 months ago

I think it's a serious issue. We are facing the same when we are trying to download back-to-back images.

tech-ajit-mob commented 9 months ago

is there any update?