Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: Attempt to invoke interface method on a null object reference #47

Open
SajadGarshasbi opened this issue Dec 30, 2021 · 1 comment

Comments

@SajadGarshasbi
Copy link

Hi, Pump crashes by calling build() method from new config

in my Application class:

private DownloadListener downloadObserver = new DownloadListener() {
/**/
}

private void initPumpDownloader() {
        Pump.newConfigBuilder()
                .setMaxRunningTaskNum(1)
                .setMinUsableStorageSpace(4 * 1024L)
                .setDownloadConnectionFactory(new OkHttpDownloadConnection.Factory(OKHttpUtil.get()))
                .build();

        downloadObserver.enable();
    }

crash:

Unable to create application com.myapp.App: java.lang.NullPointerException: Attempt to invoke interface method 'void com.huxq17.download.core.service.IDownloadConfigService.setConfig(com.huxq17.download.config.DownloadConfig)' on a null object reference
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
        at android.app.ActivityThread.access$1400(ActivityThread.java:244)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1952)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7700)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.huxq17.download.core.service.IDownloadConfigService.setConfig(com.huxq17.download.config.DownloadConfig)' on a null object reference
        at com.huxq17.download.config.DownloadConfig$Builder.build(DownloadConfig.java:90)
        at com.myapp.App.initPumpDownloader(App.java:126)
        at com.myapp.App.onCreate(App.java:87)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6754)
@SajadGarshasbi
Copy link
Author

if copy and call DownloadProvider.onCreate() contents directly inside initPumpDownloader() method, Pump works fine! 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant