Java – WorkManager could not find the required zero-parameter constructor

WorkManager could not find the required zero-parameter constructor… here is a solution to the problem.

WorkManager could not find the required zero-parameter constructor

I’m using WorkManager 1.0.0-alpha02 found in the dependency to query a web page once per minute (the query code is excluded from this example because it’s not relevant).

When I use WorkManager like this:

                        new PeriodicWorkRequest.Builder(
                                        new Constraints.Builder()

private class MessageWorker extends Worker {
        public MessageWorker() {

        public WorkerResult doWork() {
             Do stuff
            return WorkerResult.SUCCESS;

It gives this error message:

05-31 17:50:05.645 11749-12168/com.neelkamath.webview E/WorkerWrapper: Trouble instantiating com.neelkamath.webview.MainActivity$MessageWorker
    java.lang.InstantiationException: java.lang.Class<com.neelkamath.webview.MainActivity$MessageWorker> has no zero argument constructor
        at java.lang.Class.newInstance(Native Method)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$
05-31 17:50:05.645 11749-12168/com.neelkamath.webview E/WorkerWrapper: Could for create Worker com.neelkamath.webview.MainActivity$MessageWorker

I’ve tried the following constructors to no avail:

  • There is no constructor
  • Public
  • Private
  • A constructor with a non-empty body, the only statement is super();


Remove the following constructor from the MessageWorker and make the class public. :

public MessageWorker() {

Also make sure that the class is in a separate file.

Related Problems and Solutions