Skip to content

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

@SajadGarshasbi

Description

@SajadGarshasbi

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions