Skip to content

Conversation

@nathan9513-aps
Copy link

Summary

Fixed a critical crash in the Consorsbank Banking App caused by a ClassCastException where a NullPointerException was being incorrectly cast to ApiException. The crash occurred when the Google Wallet API integration attempted to handle null status objects.

Problem Description

The Consorsbank Banking App (version 2.4.1) was crashing immediately after login on /e/OS 3.4-a15 with the following error:

FATAL EXCEPTION: main
Process: de.consorsbank, PID: 7618
java.lang.ClassCastException: java.lang.NullPointerException cannot be cast to com.google.android.gms.common.api.ApiException
    at de.consorsbank.neo.cards.data.repository.wallet.GoogleWalletApi$d.onComplete:109
    at com.google.android.gms.tasks.x.run:20
    at android.os.Handler.handleCallback(Handler.java:991)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8934)

Root Cause Analysis

The crash was caused by multiple issues in GoogleSignIn.getSignedInAccountFromIntent():

  1. Missing Status Import: The Status class was not imported, causing compilation errors
  2. Null Status Handling: The code attempted to create ApiException from null Status objects without proper null checks
  3. Missing Null Guard: No defensive programming against potential null returns from GoogleSignInCommon.getSignInResultFromIntent()

Solution Implemented

1. Added Missing Import

import com.google.android.gms.common.api.Status;

2. Enhanced Null Safety for Status Objects

Status status = signInResultFromIntent.getStatus();
if (!signInResultFromIntent.isSuccess() || signInAccount == null) {
    if (status == null) {
        return Tasks.forException(new ApiException(Status.INTERNAL_ERROR));
    } else {
        return Tasks.forException(new ApiException(status));
    }
}

3. Added Defensive Null Guard

GoogleSignInResult signInResultFromIntent = GoogleSignInCommon.getSignInResultFromIntent(data);
if (signInResultFromIntent == null) {
    return Tasks.forException(new ApiException(Status.INTERNAL_ERROR));
}

Enhanced error handling in GoogleSignIn.getSignedInAccountFromIntent() by adding null checks for the Status object and providing more specific error messages. This prevents potential NullPointerExceptions and ensures proper error propagation when sign-in fails or returns null accounts.
Added the missing `com.google.android.gms.common.api.Status` import to the GoogleSignIn class to resolve compilation issues.
Added null check for GoogleSignInResult before accessing its methods to prevent potential NullPointerException when the intent data is null or invalid.
fix: improve error handling in getSignedInAccountFromIntent method
@nathan9513-aps nathan9513-aps closed this by deleting the head repository Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant