{"record":{"id":"fe2d79fc698ae17d","repo":"microg/GmsCore","slug":"addoncompletelistener-is-not-implemented","errorCode":null,"errorMessage":"addOnCompleteListener is not implemented","messagePattern":"addOnCompleteListener is not implemented","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java","lineNumber":72,"sourceCode":"     * The listener will be automatically removed during {@link Activity#onStop()}.\n     *\n     * @return this Task\n     */\n    public Task<TResult> addOnCanceledListener(Activity activity, OnCanceledListener listener) {\n        throw new UnsupportedOperationException(\"addOnCanceledListener is not implemented\");\n    }\n\n    /**\n     * Adds a listener that is called when the Task completes.\n     * <p/>\n     * The listener will be called on main application thread. If the Task is already complete, a\n     * call to the listener will be immediately scheduled. If multiple listeners are added, they\n     * will be called in the order in which they were added.\n     *\n     * @return this Task\n     */\n    public Task<TResult> addOnCompleteListener(OnCompleteListener<TResult> listener) {\n        throw new UnsupportedOperationException(\"addOnCompleteListener is not implemented\");\n    }\n\n    /**\n     * Adds an Activity-scoped listener that is called when the Task completes.\n     * <p/>\n     * The listener will be called on main application thread. If the Task is already complete, a\n     * call to the listener will be immediately scheduled. If multiple listeners are added, they\n     * will be called in the order in which they were added.\n     * <p/>\n     * The listener will be automatically removed during {@link Activity#onStop()}.\n     *\n     * @return this Task\n     */\n    public Task<TResult> addOnCompleteListener(Activity activity, OnCompleteListener<TResult> listener) {\n        throw new UnsupportedOperationException(\"addOnCompleteListener is not implemented\");\n    }\n\n    /**","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade to a library version whose Task implementations override addOnCompleteListener","Obtain Tasks only from implementations that support listeners (e.g. TaskCompletionSource-produced Task","Use Tasks.await(task) or alternative completion mechanisms where available","Catch UnsupportedOperationException and fall back to polling isComplete()/getResult()"],"exampleFix":"// before\ntask.addOnCompleteListener(listener); // throws\n// after\ntry {\n    task.addOnCompleteListener(listener);\n} catch (UnsupportedOperationException e) {\n    TResult r = Tasks.await(task); // fallback\n    listener.onComplete(Tasks.forResult(r));\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    task.addOnCompleteListener(listener);\n} catch (UnsupportedOperationException e) {\n    TResult result = Tasks.await(task);\n    listener.onComplete(Tasks.forResult(result));\n}","preventionTips":["Only attach completion listeners to Task subclasses that override addOnCompleteListener","Check whether Tasks produced by withTimeout/execute support listeners before chaining","Prefer Tasks.await for blocking flows when listener support is uncertain"],"tags":["unsupported-operation","tasks","listeners"],"backgroundTag":"unsupported-operation","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}