Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

JobSchedulerAPI NullPointerException with --network none on Android 17

Open Beginner friendly
#923 0 comments 0 reactions 0 assignees View on GitHub

@Mayank-jaiswal13 is already working on this.

Since Oct 19, 2026.

  • #924 by @Mayank-jaiswal13 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, java
Domain
mobile

Research direction

Start with JobSchedulerAPI.formatJobInfo() and reproduce the failure by scheduling a periodic job with --network none, then listing it with termux-job-scheduler --pending. Check how JobInfo.getRequiredNetwork() is formatted when it returns null, and handle that case without changing the scheduling behavior for jobs requiring a network. Done means both scheduling and listing a network-free job complete without an exception and display its information correctly.

Written by the indexing model from the issue text.

Description

Description

Termux:API 0.53.0 throws a NullPointerException when scheduling a job using termux-job-scheduler --network none.

The job appears to register successfully, but Termux:API crashes when formatting its information. Running termux-job-scheduler --pending subsequently produces the same exception.

Changing the network requirement to --network any resolves both errors.

Steps to Reproduce

  1. Schedule a periodic job without a network requirement:

    termux-job-scheduler \
      --script "$HOME/dev/android-backup-cleanup/run.sh" \
      --job-id 101 \
      --period-ms 604800000 \
      --persisted true \
      --network none \
      --battery-not-low true
    
  2. Observe the following exception:

    java.lang.NullPointerException:
    Attempt to invoke virtual method
    'java.lang.String android.net.NetworkRequest.toString()'
    on a null object reference
    

    at com.termux.api.apis.JobSchedulerAPI.formatJobInfo(SourceFile:57)
    at com.termux.api.apis.JobSchedulerAPI.runScheduleJobAction(SourceFile:185)

  3. List pending jobs:

    termux-job-scheduler --pending
    
  4. Observe another exception:

    java.lang.NullPointerException:
    Attempt to invoke virtual method
    'java.lang.String android.net.NetworkRequest.toString()'
    on a null object reference
    

    at com.termux.api.apis.JobSchedulerAPI.formatJobInfo(SourceFile:57)
    at com.termux.api.apis.JobSchedulerAPI.displayPendingJobs(SourceFile:253)
    at com.termux.api.apis.JobSchedulerAPI.runDisplayPendingJobsAction(SourceFile:195)

  5. Reschedule the same job with --network any:

    termux-job-scheduler \
      --script "$HOME/dev/android-backup-cleanup/run.sh" \
      --job-id 101 \
      --period-ms 604800000 \
      --persisted true \
      --network any \
      --battery-not-low true
    
  6. Scheduling now succeeds, and termux-job-scheduler --pending correctly displays Job 101.

Expected Behavior

  • Scheduling with --network none should succeed without exceptions.
  • termux-job-scheduler --pending should display jobs that do not require network connectivity.
  • A null network requirement should be handled gracefully.

Actual Behavior

  • Scheduling with --network none throws a NullPointerException.
  • Listing pending jobs also throws a NullPointerException.
  • Using --network any prevents the crashes but unnecessarily requires network connectivity for offline jobs.

Suspected Cause

The stack trace points to JobSchedulerAPI.formatJobInfo() calling toString() on a null android.net.NetworkRequest.

Android's JobInfo.getRequiredNetwork() can return null when no network is required.

A null check before formatting the network requirement should prevent this exception.

Environment

Component Version
Device Google Pixel 9
Android 17 (API 37)
Android build CP3A.261005.005
Security patch 2026-10-05
Termux 0.118.3
Termux:API 0.53.0
Installation source F-Droid
Termux:API target SDK 28

Workaround

Using --network any avoids the crash:

termux-job-scheduler --pending

This command successfully lists the registered job after rescheduling with --network any.

However, requiring network connectivity is unnecessary for jobs that operate entirely offline.

Additional Notes

The exception occurs while formatting job information rather than directly inside Android's job scheduling call.

The subsequent exception when listing pending jobs suggests the original job may have been registered, although that was not independently verified.

This appears to be a null-handling issue in Termux:API's JobScheduler response formatting.

Dominant language
Java
Stars
4.5k
Forks
969
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from termux/termux-api

All issues in termux/termux-api

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.