{"record":{"id":"36abc2b9231ae8e4","repo":"lingochamp/FileDownloader","slug":"task-d-can-t-start-the-download-runnable-becaus","errorCode":null,"errorMessage":"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.","messagePattern":"Task\\[(.+?)\\] can't start the download runnable, because this task require wifi, but user application nor current process has (.+?), so we can't check whether the network type connection\\.","errorType":"exception","errorClass":"FileDownloadGiveUpRetryException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java","lineNumber":901,"sourceCode":"            FileDownloadLog.e(this, \"valid retry times is less than 0(%d) for download task(%d)\",\n                    validRetryTimes, model.getId());\n        }\n\n        statusCallback.onRetry(exception, validRetryTimes);\n    }\n\n    @Override\n    public void syncProgressFromCache() {\n        database.updateProgress(model.getId(), model.getSoFar());\n    }\n\n    private void checkupBeforeConnect()\n            throws FileDownloadGiveUpRetryException {\n\n        // 1. check whether need access-network-state permission?\n        if (isWifiRequired\n                && !FileDownloadUtils.checkPermission(Manifest.permission.ACCESS_NETWORK_STATE)) {\n            throw new FileDownloadGiveUpRetryException(\n                    FileDownloadUtils.formatString(\"Task[%d] can't start the download runnable,\"\n                                    + \" because this task require wifi, but user application \"\n                                    + \"nor current process has %s, so we can't check whether \"\n                                    + \"the network type connection.\", model.getId(),\n                            Manifest.permission.ACCESS_NETWORK_STATE));\n        }\n\n        // 2. check whether need wifi to download?\n        if (isWifiRequired && FileDownloadUtils.isNetworkNotOnWifiType()) {\n            throw new FileDownloadNetworkPolicyException();\n        }\n    }\n\n    private void checkupAfterGetFilename() throws RetryDirectly, DiscardSafely {\n        final int id = model.getId();\n\n        if (model.isPathAsDirectory()) {\n            // this scope for caring about the case of there is another task is provided","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/download/DownloadLaunchRunnable.java#L883-L919","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before: AndroidManifest.xml missing the permission\n<uses-permission android:name=\"android.permission.INTERNET\"/>\n// after\n<uses-permission android:name=\"android.permission.INTERNET\"/>\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>","handlingStrategy":"validation","validationCode":"boolean hasPermission = ContextCompat.checkSelfPermission(context,\n    Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED;\nif (!hasPermission && wifiRequired) {\n    throw new IllegalStateException(\"ACCESS_NETWORK_STATE permission required for wifi-required downloads\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    FileDownloader.getImpl().create(url).setPath(path).setWifiRequired(true).start(listener);\n} catch (FileDownloadGiveUpRetryException e) {\n    // no retry possible; request the permission or disable wifi-required\n    requestPermissionOrDisableWifiOnly();\n}","preventionTips":["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"],"tags":["android","permissions","wifi","file-download"],"backgroundTag":"permission-denied","analyzedSha":"6237a8cac174bcc916e4342b14ab1ab72a5768d4","analyzedAt":"2026-09-08T23:50:48.168Z","contentChangedAt":"2026-09-08T23:50:48.168Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}