I did everything according to the instructions and an error occurs:

java.lang.ExceptionInInitializerError Caused by: java.lang.IllegalStateException: Please invoke the FileDownloader#init in Application#onCreate first. 

By mistake, it is clear that you need to initialize the FileDownloader class. But I have initialization code. Put instead getApplicationContext(), this , the same error. Here is the code for the button that I click to download:

 FileDownloader.init(getApplicationContext()); final FileDownloadListener queueTarget = new FileDownloadListener() { @Override protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes) {} @Override protected void connected(BaseDownloadTask task, String etag, boolean isContinue, int soFarBytes, int totalBytes) {} @Override protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes) {} @Override protected void blockComplete(BaseDownloadTask task) {} @Override protected void retry(final BaseDownloadTask task, final Throwable ex, final int retryingTimes, final int soFarBytes) {} @Override protected void completed(BaseDownloadTask task) {} @Override protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes) {} @Override protected void error(BaseDownloadTask task, Throwable e) {} @Override protected void warn(BaseDownloadTask task) {} }; FileDownloader.getImpl().create("https://pp.vk.me/c7001/v7001597/2006f/s-Hx1H7aMog.jpg") .setPath(getFilesDir().toString()) .setListener(queueTarget) .addHeader("Name","Value") .start(); 

Library in GitHub https://github.com/lingochamp/FileDownloader

    1 answer 1

    It's written

    Please invoke the FileDownloader # init in Application # onCreate first.

    Transfer the FileDownloader.init(...) to the onCreate class that inherits the Application and write in the manifest:

     <application android:name=".AppYourClassName" ... > 

    Example links: project class and project manifest