microg/GmsCore · error · UnsupportedOperationException
addOnCanceledListener is not implemented
Error message
addOnCanceledListener is not implemented
What it means
Task.addOnCanceledListener(OnCanceledListener) is declared in this library's abstract Task class but not implemented; it unconditionally throws UnsupportedOperationException 'addOnCanceledListener is not implemented'. Subclasses are expected to override it; calling it on the base/default implementation always fails.
Solutions
- Upgrade to a library version whose concrete Task classes implement addOnCanceledListener
- Avoid addOnCanceledListener; use addOnCompleteListener and check task.isCanceled() instead
- Wrap in try-catch for UnsupportedOperationException if cancel notification is optional
- Use a fully implemented Task subclass (e.g. Task from a real TaskCompletionSource flow)
Example fix
// before
task.addOnCanceledListener(listener); // throws
// after
task.addOnCompleteListener(t -> {
if (t.isCanceled()) listener.onCanceled();
}); Defensive patterns
Strategy: try-catch
Try / catch
try {
task.addOnCanceledListener(listener);
} catch (UnsupportedOperationException e) {
task.addOnCompleteListener(t -> { if (t.isCanceled()) listener.onCanceled(); });
} Prevention
- Prefer addOnCompleteListener + isCanceled() checks over addOnCanceledListener in this library
- Pin a library version known to implement cancel listeners before adopting the API
When it happens
Trigger: Registering a cancel listener via the single-argument overload on any Task instance that inherits the base implementation (e.g. a Task returned by an API that does not override this method).
Common situations: Using this library's play-services-tasks port (e.g. microG) and adding cancel listeners as in official Google Play Services code; the port lacks the override in the Task implementation being used.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- addOnCompleteListener is not implemented
- continueWith is not implemented
- continueWithTask is not implemented
- onSuccessTask is not implemented
- Cannot remove elements from a DataBufferIterator
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/1fc3a4200c705473.
Report an issue: GitHub.
Appendix: source
Thrown at play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java:34
/**
* Represents an asynchronous operation.
*/
@PublicApi
public abstract class Task<TResult> {
public Task() {
}
/**
* Adds a listener that is called if the Task is canceled.
* <p>
* The listener will be called on main application thread. If the Task has already been canceled, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.
*
* @return this Task
*/
public Task<TResult> addOnCanceledListener(OnCanceledListener listener) {
throw new UnsupportedOperationException("addOnCanceledListener is not implemented");
}
/**
* Adds a listener that is called if the Task is canceled.
* <p>
* If the Task has already been canceled, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.
*
* @param executor the executor to use to call the listener
* @return this Task
*/
public Task<TResult> addOnCanceledListener(Executor executor, OnCanceledListener listener) {
throw new UnsupportedOperationException("addOnCanceledListener is not implemented");
}
/**
* Adds an Activity-scoped listener that is called if the Task is canceled.
* <p>
* The listener will be called on main application thread. If the Task has already been canceled, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.View on GitHub (pinned to 157c9d86ac)