lingochamp/FileDownloader · error · FileDownloadGiveUpRetryException
Task[ ] can't start the download runnable, because this…
Error message
Task[%d] can't start the download runnable, because this task require wifi, but user application nor current process has %s, so we can't check whether the network type connection.
What it means
FileDownloadGiveUpRetryException thrown from checkupBeforeConnect (constructor/run path of DownloadLaunchRunnable) when the task requires WiFi but the app lacks the android.permission.ACCESS_NETWORK_STATE permission, so FileDownloader cannot verify the current network is WiFi. It is a 'give up retry' error: the task will not be retried because the condition cannot be satisfied without the permission.
Solutions
- Add <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> to AndroidManifest.xml
- Remove or set false the wifi-required flag on the task if network-type checking is not truly needed
- Check FileDownloadUtils.checkPermission(Manifest.permission.ACCESS_NETWORK_STATE) before enabling WiFi-required mode and handle gracefully
- Verify the merged manifest of the final APK (manifest merger can drop permissions from flavors/builds)
Example fix
// before: AndroidManifest.xml missing the permission <uses-permission android:name="android.permission.INTERNET"/> // after <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Defensive patterns
Strategy: validation
Validate before calling
boolean hasPermission = ContextCompat.checkSelfPermission(context,
Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED;
if (!hasPermission && wifiRequired) {
throw new IllegalStateException("ACCESS_NETWORK_STATE permission required for wifi-required downloads");
} Try / catch
try {
FileDownloader.getImpl().create(url).setPath(path).setWifiRequired(true).start(listener);
} catch (FileDownloadGiveUpRetryException e) {
// no retry possible; request the permission or disable wifi-required
requestPermissionOrDisableWifiOnly();
} Prevention
- Always declare INTERNET and ACCESS_NETWORK_STATE in AndroidManifest.xml
- Check permission state before enabling setWifiRequired(true)
- Verify the merged manifest in release builds/flavors
- Handle FileDownloadGiveUpRetryException distinctly from retryable errors — it will never succeed on retry without a code/config change
When it happens
Trigger: Calling FileDownloader create(...).setWifiRequired(true).start() (or equivalent) in an app whose AndroidManifest does not declare ACCESS_NETWORK_STATE; the check runs before connecting, so the task aborts immediately.
Common situations: Migrating to FileDownloader and forgetting to add all required permissions (INTERNET plus ACCESS_NETWORK_STATE); enabling WiFi-only mode in a build variant whose manifest was not updated; Android 6.0+ permission stripping in some manifest merger configurations.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Create parent directory failed, please make sure you have…
- response code error: , request headers: response headers
- the download runnable must not be null!
- The file is too large to store, breakpoint in bytes
- Connection failed with request
AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08).
Data as JSON: /api/errors/36abc2b9231ae8e4.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java:901
FileDownloadLog.e(this, "valid retry times is less than 0(%d) for download task(%d)",
validRetryTimes, model.getId());
}
statusCallback.onRetry(exception, validRetryTimes);
}
@Override
public void syncProgressFromCache() {
database.updateProgress(model.getId(), model.getSoFar());
}
private void checkupBeforeConnect()
throws FileDownloadGiveUpRetryException {
// 1. check whether need access-network-state permission?
if (isWifiRequired
&& !FileDownloadUtils.checkPermission(Manifest.permission.ACCESS_NETWORK_STATE)) {
throw new FileDownloadGiveUpRetryException(
FileDownloadUtils.formatString("Task[%d] can't start the download runnable,"
+ " because this task require wifi, but user application "
+ "nor current process has %s, so we can't check whether "
+ "the network type connection.", model.getId(),
Manifest.permission.ACCESS_NETWORK_STATE));
}
// 2. check whether need wifi to download?
if (isWifiRequired && FileDownloadUtils.isNetworkNotOnWifiType()) {
throw new FileDownloadNetworkPolicyException();
}
}
private void checkupAfterGetFilename() throws RetryDirectly, DiscardSafely {
final int id = model.getId();
if (model.isPathAsDirectory()) {
// this scope for caring about the case of there is another task is providedView on GitHub (pinned to 6237a8cac1)