AuthenticationActivity cannot be cast to androidx.fragment.app.B

We have noticed users that click on our login button and instantly a crash in being throw:

java.lang.ClassCastException: com.auth0.android.provider.AuthenticationActivity cannot be cast to androidx.fragment.app.B
at L5.L1.a(SourceFile:27)
at L5.Q0.onActivityCreated(Unknown Source:10)
at android.app.Application.dispatchActivityCreated(Application.java:368)
at android.app.Activity.dispatchActivityCreated(Activity.java:1544)
at android.app.Activity.onCreate(Activity.java:1844)
at com.auth0.android.provider.AuthenticationActivity.onCreate(Unknown Source:0)
at android.app.Activity.performCreate(Activity.java:9021)
at android.app.Activity.performCreate(Activity.java:8999)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1527)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4050)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4255)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:112)
at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:179)
at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:114)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:86)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2656)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8791)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:585)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908)
App foregrounded on org.mahhp
Binding to activity: com.auth0.android.provider.AuthenticationActivity
Setting display event component
Session: validateAndStartVerification called with manual=false
Found TWA provider, finishing search: com.android.chrome
Trying to bind the service
Bind request result (com.android.chrome): true
Trying to bind the service
Bind request result (com.android.chrome): true
Access denied finding property “vendor.display.enable_optimal_refresh_rate”
Access denied finding property “vendor.gpp.create_frc_extension”
type=1400 audit(0.0:287648): avc: denied { read } for name=“u:object_r:vendor_display_prop:s0” dev=“tmpfs” ino=433 scontext=u:r:untrusted_app:s0:c18,c257,c512,c768 tcontext=u:object_r:vendor_display_prop:s0 tclass=file permissive=0 app=org.mahhp
CustomTabs Service connected
Launching URI. Custom Tabs available: true
Event: {ORACLE_SIGNUP_AUTH0_EXP_CARD_TAP: null}
The Callback URI is: org.mahhp://login.lyfeos.org/android/org.mahhp/callback
Using PKCE authentication flow
Using the following Authorize URI: https://login.lyfeos.org/authorize?scope=openid%20profile%20email%20offline_access&audience=prod-mahhp-authorizer-api&screen_hint=signup&prompt=login&response_type=code&code_challenge=K0jnN0a5DCSccojK-PO3H0d0MnLKoZKT58fRi7pCLHU&code_challenge_method=S256&auth0Client=eyJuYW1lIjoiYXV0aDAtZmx1dHRlciIsImVudiI6eyJhbmRyb2lkIjoiMzUifSwidmVyc2lvbiI6IjEuMTQuMCJ9&client_id=aZS3eG9nQkLAvaTrBJE2zd77r50FnK6u&redirect_uri=org.mahhp%3A%2F%2Flogin.lyfeos.org%2Fandroid%2Forg.mahhp%2Fcallback&state=X0PuaARYOq8gkIWlwOY7vj2sEPckbntUcfTGQIo_QtU&nonce=eSCIPWQALp5-nCfX0veUtJl0NGCz7lxVdrEz1DNRfyY
App backgrounded on org.mahhp
Unbinding from activity: com.auth0.android.provider.AuthenticationActivity
Removing display event component
App foregrounded on org.mahhp
Binding to activity: com.auth0.android.provider.AuthenticationActivity
Setting display event component
App backgrounded on org.mahhp
Unbinding from activity: com.auth0.android.provider.AuthenticationActivity
Removing display event component
Session: validateAndStartVerification called with manual=false
Event: {SIGNUP_ERROR: {test-3.0.1-assignedAt=2025-12-01, test-3.0.1-totalVariants=2, test-3.0.1-variantId=1, error=The user closed the browser app and the authentication was canceled.}}

@support here’s the requested forum

Hi @rafaelplantard

Welcome to the Auth0 Community!

What I understand from the ClassCastException error you have received, it might be caused by your some code in your application which globally monitors all activities and presumes they all are inherited from a specific/single class. The Auth0 SDK provides its own activity which inherits the standard Android one, caches it and attempts to cast it over FragmentActivity causing the crash.

My recommendation would be to find where registerActivityLifecycleCallbacks is called in your Application class and wrap the cast in a check like this:

@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    if (activity instanceof FragmentActivity) {
        ((FragmentActivity) activity).getSupportFragmentManager();
    }
}

The issue might also be called by a 3rd party library which you would need to update or contact the owner of those libraries specifically.

If you have any other questions, let me know!

Kind Regards,
Nik

I don’t think it’s our own activity, because it’s very simple:

package org.mahhp

import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.Window
import android.window.OnBackInvokedDispatcher
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat.setDecorFitsSystemWindows
import com.clevertap.android.sdk.CleverTapAPI
import com.singular.flutter_sdk.SingularBridge
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.PhoneShakerPlugin

class MainActivity : FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        installSplashScreen()

        super.onCreate(savedInstanceState)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            onBackInvokedDispatcher.registerOnBackInvokedCallback(
                OnBackInvokedDispatcher.PRIORITY_DEFAULT
            ) {
                finish()
            }
        }

        setDecorFitsSystemWindows(window, false)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            intent?.extras?.let { extras ->
                CleverTapAPI.getDefaultInstance(this)?.pushNotificationClickedEvent(extras)
            }
        }
    }

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)

        // Register the PhoneShakerPlugin
        flutterEngine.plugins.add(PhoneShakerPlugin())
    }

    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)

        setIntent(intent)

        if (intent.data != null) {
            SingularBridge.onNewIntent(intent)
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            intent.extras?.let { extras ->
                CleverTapAPI.getDefaultInstance(this)?.pushNotificationClickedEvent(extras)
            }
        }
    }
}

this error occurs with a user when they tried to open the login flow from Auth0, it throws an generic exception in the auth0’s flutter sdk, but we don’t understand why for some users are failing.