I Found this error : class file for com.google.common.util.concurrent.ListenableFuture not found

I Found this error : class file for com.google.common.util.concurrent.ListenableFuture not found

...BudgetNotificationWorker.java:14: error: cannot access ListenableFuture public class BudgetNotificationWorker extends Worker { ^ class file for com.google.common.util.concurrent.ListenableFuture not found

I am trying to implement a Worker in my Android app to check budget conditions in the background using WorkManager. I expected it to compile and run periodically to show notifications based on income and expense data. However, I got a compilation error: cannot access ListenableFuture.

Answer

If you're using the Worker class and overriding the doWork() method, then ListenableFuture shouldn’t be needed directly.

Here’s a basic example of using Worker correctly:

public class BudgetNotificationWorker extends Worker {

public BudgetNotificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {

    super(context, workerParams);

}

@NonNull

@Override

public Result doWork() {

    // Your budget checking and notification logic here

    return Result.success(

);

}

}

Enjoyed this question?

Check out more content on our blog or follow us on social media.

Browse more questions