microg/GmsCore · error · UnsupportedOperationException

addOnCompleteListener is not implemented

Error message

addOnCompleteListener is not implemented

What it means

Task.addOnCompleteListener(OnCompleteListener<TResult>) is a stub in the base Task class that throws UnsupportedOperationException 'addOnCompleteListener is not implemented'. It is only usable on concrete Task subclasses that override it; on the base/default implementation every call fails.

Source

Thrown at play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java:72

     * The listener will be automatically removed during {@link Activity#onStop()}.
     *
     * @return this Task
     */
    public Task<TResult> addOnCanceledListener(Activity activity, OnCanceledListener listener) {
        throw new UnsupportedOperationException("addOnCanceledListener is not implemented");
    }

    /**
     * Adds a listener that is called when the Task completes.
     * <p/>
     * The listener will be called on main application thread. If the Task is already complete, 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> addOnCompleteListener(OnCompleteListener<TResult> listener) {
        throw new UnsupportedOperationException("addOnCompleteListener is not implemented");
    }

    /**
     * Adds an Activity-scoped listener that is called when the Task completes.
     * <p/>
     * The listener will be called on main application thread. If the Task is already complete, 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.
     * <p/>
     * The listener will be automatically removed during {@link Activity#onStop()}.
     *
     * @return this Task
     */
    public Task<TResult> addOnCompleteListener(Activity activity, OnCompleteListener<TResult> listener) {
        throw new UnsupportedOperationException("addOnCompleteListener is not implemented");
    }

    /**

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Upgrade to a library version whose Task implementations override addOnCompleteListener
  2. Obtain Tasks only from implementations that support listeners (e.g. TaskCompletionSource-produced Task
  3. Use Tasks.await(task) or alternative completion mechanisms where available
  4. Catch UnsupportedOperationException and fall back to polling isComplete()/getResult()

Example fix

// before
task.addOnCompleteListener(listener); // throws
// after
try {
    task.addOnCompleteListener(listener);
} catch (UnsupportedOperationException e) {
    TResult r = Tasks.await(task); // fallback
    listener.onComplete(Tasks.forResult(r));
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    task.addOnCompleteListener(listener);
} catch (UnsupportedOperationException e) {
    TResult result = Tasks.await(task);
    listener.onComplete(Tasks.forResult(result));
}

Prevention

When it happens

Trigger: Calling the single-listener completion overload on a Task returned from an API whose Task class does not override addOnCompleteListener. Known callers include withTimeout and execute in this library, so wrapping such Task results with listeners fails.

Common situations: Blocking on or observing results of Tasks produced by this library's utilities (withTimeout/execute) or by APIs using the unimplemented base Task — common when using microG's play-services-tasks port with code written for official Play Services.

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


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/fe2d79fc698ae17d. Report an issue: GitHub.