Skip to content

Fixing the 'Specify a Valid Range of Job IDs for WorkManager to Use' Warning in Android Studio

Android Studio, WorkManager, Kotlin1 min read

If you're working on an Android app that uses WorkManager, you may have come across the warning message "Specify a valid range of job id's for WorkManager to use". This warning indicates that WorkManager is trying to schedule jobs using invalid or out-of-range job IDs.

WorkManager relies on the Android system's JobScheduler API to schedule and run background tasks, and JobScheduler requires that each scheduled job has a unique integer ID. By default, WorkManager generates job IDs automatically, but you can also specify your own IDs if needed.

To avoid the "Specify a valid range of job id's for WorkManager to use" warning, you can use the setJobSchedulerJobIdRange() method in Kotlin to set a valid range for job IDs that WorkManager can use. Here's how:

  1. Open your app's build.gradle file and add the following dependency:
1dependencies {
2 implementation ""
  1. In your app's Application class or another appropriate place, initialize WorkManager with a configuration that sets the valid job ID range:
5class MyApp : Application() {
7 override fun onCreate() {
8 super.onCreate()
10 val config = Configuration.Builder()
11 .setMinimumLoggingLevel(android.util.Log.INFO)
12 .setJobSchedulerJobIdRange(1000, 2000) // Set the job ID range here
13 .build()
15 WorkManager.initialize(this, config)
16 }

Or alternatively(you can read more about custom configuration for WorkManager in the documentation here):

1class MyApp : Application(), Configuration.Provider {
2 override fun getWorkManagerConfiguration() =
3 Configuration.Builder()
4 .setMinimumLoggingLevel(android.util.Log.INFO)
5 .setJobSchedulerJobIdRange(1000, 2000) // Set the job ID range here
6 .build()

In this example, we set the valid job ID range to be between 1000 and 2000. You can choose any valid range of integers that suits your needs.

Once you've set the job ID range using setJobSchedulerJobIdRange(), WorkManager will only generate job IDs within that range, which will prevent the "Specify a valid range of job id's for WorkManager to use" warning from appearing in Android Studio.