lingochamp/FileDownloader · error · IllegalStateException

Please invoke the 'FileDownloader#setup' before using…

Error message

Please invoke the 'FileDownloader#setup' before using FileDownloader. If you want to register some components on FileDownloader please invoke the 'FileDownloader#setupOnApplicationOnCreate' on the 'Application#onCreate' first.

What it means

Error "Please invoke the 'FileDownloader#setup' before using FileDownloader. If you want to register some components on FileDownloader please invoke the 'FileDownloader#setupOnApplicationOnCreate' on the 'Application#onCreate' first." thrown in lingochamp/FileDownloader.

Solutions

  1. Call FileDownloader.setup(context) (or FileDownloader.setupOnApplicationOnCreate(application)) once, e.g. in Application#onCreate, before any download call
  2. When registering custom components (output stream, id generator, etc.), use FileDownloader.setupOnApplicationOnCreate in Application#onCreate first, then setup(context)
  3. Avoid keeping the process alive with no Application#onCreate running: ensure setup runs in every process that uses FileDownloader
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadProperties.java:162 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08). Data as JSON: /api/errors/6e8add5519209dec. Report an issue: GitHub.

Appendix: source

Thrown at library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadProperties.java:162

    public final boolean fileNonPreAllocation;
    public final boolean broadcastCompleted;
    public final boolean trialConnectionHeadMethod;

    public static class HolderClass {
        private static final FileDownloadProperties INSTANCE = new FileDownloadProperties();
    }

    public static FileDownloadProperties getImpl() {
        return HolderClass.INSTANCE;
    }

    private static final String TRUE_STRING = "true";
    private static final String FALSE_STRING = "false";

    // init properties, normally consume <= 2ms
    private FileDownloadProperties() {
        if (FileDownloadHelper.getAppContext() == null) {
            throw new IllegalStateException("Please invoke the 'FileDownloader#setup' before using "
                    + "FileDownloader. If you want to register some components on FileDownloader "
                    + "please invoke the 'FileDownloader#setupOnApplicationOnCreate' on the "
                    + "'Application#onCreate' first.");
        }

        final long start = System.currentTimeMillis();
        String httpLenient = null;
        String processNonSeparate = null;
        String downloadMinProgressStep = null;
        String downloadMinProgressTime = null;
        String downloadMaxNetworkThreadCount = null;
        String fileNonPreAllocation = null;
        String broadcastCompleted = null;
        String downloadTrialConnectionHeadMethod = null;

        Properties p = new Properties();
        InputStream inputStream = null;

View on GitHub (pinned to 6237a8cac1)