androidandroid-jobschedulerandroid-job

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/app/job/JobInfo$TriggerContentUri;


I am using JobScheduler with addTriggerContentUri observing for any changes in the specific content uri. When I run the app I get the above exception.


Solution

  • addTriggerContentUri is available in JobInfo in API 24 (Nougat) and above. If you try this in any device below API 24 you won’t get any compile time error but during run time Android will try to find the addTriggerContentUri in JobInfo which won’t be available and will throw above exception (Caused
    by: java.lang.ClassNotFoundException: Didn't find class "android.app.job.JobInfo$TriggerContentUri" on path: DexPathList[[zip file "/data/app/).

    Solution : You can have API level check before calling this method.

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
     ....
    }