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

**URL:** <https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [December 2, 2025, 7:19pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131 "2025-12-02T19:19:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafaelplantard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rafaelplantard/32/77671_2.png) [@rafaelplantard](https://community.auth0.com/u/rafaelplantard)\
**Post date:** [December 2, 2025, 7:19pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/1 "2025-12-02T19:19:22Z")

</div>

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](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.}}

---

<div class="post-metadata">

**Author:** ![rafaelplantard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rafaelplantard/32/77671_2.png) [@rafaelplantard](https://community.auth0.com/u/rafaelplantard)\
**Post date:** [December 2, 2025, 7:20pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/2 "2025-12-02T19:20:29Z")

</div>

[@support](https://community.auth0.com/groups/support) here’s the requested forum

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [December 4, 2025, 5:38pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/4 "2025-12-04T17:38:43Z")

</div>

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:

```auto
@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

---

<div class="post-metadata">

**Author:** ![rafaelplantard](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rafaelplantard/32/77671_2.png) [@rafaelplantard](https://community.auth0.com/u/rafaelplantard)\
**Post date:** [December 4, 2025, 8:26pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/5 "2025-12-04T20:26:56Z")

</div>

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

```kotlin
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.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [December 9, 2025, 4:01pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/6 "2025-12-09T16:01:36Z")

</div>

Hi again @rafaelplantard

I am not saying that there might be some misconfiguration in regards to your own Activity, but how the application interacts with it, expecting you to use the Auth0 SDKs activity. Because of this, you application might be caching your Activity and since the SDK is expecting you to use the one it already inherits, it is throwing the error. I am not 100% familiar with the SDK however that is my assumption regarding the issue.

By any chance, were you able to replicate this issue when using our [sample](https://github.com/auth0-samples/auth0-flutter-samples/tree/main/sample) application? Also, you can try opening an [issue](https://github.com/auth0-samples/auth0-flutter-samples/issues) on the Github page for further troubleshooting.

Let me know if you have any further updates on the matter!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 23, 2025, 4:02pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/7 "2025-12-23T16:02:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [November 20, 2026, 12:35pm UTC](https://community.auth0.com/t/authenticationactivity-cannot-be-cast-to-androidx-fragment-app-b/195131/8 "2026-11-20T12:35:19Z")

</div>

Hi everyone, as we are updating and optimizing the information on our community, I will be providing more information on the matter!

## [Root Cause]

The stack trace points directly to where and why the crash occurs:

```auto
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 com.auth0.android.provider.AuthenticationActivity.onCreate(Unknown Source:0)

```

1. `ActivityLifecycleCallbacks` Global Hook:  
An `Application.ActivityLifecycleCallbacks` listener (registered either directly in your Android `Application` class or injected by a third-party SDK/Flutter plugin) is listening to **every** activity creation lifecycle event via `onActivityCreated(Activity activity, Bundle savedInstanceState)`.

2. **The Unsafe Cast** :  
Inside that callback (`L5.Q0.onActivityCreated` calling obfuscated class `L5.L1`), the code blindly assumes that every activity created in the application is a `FragmentActivity` / `AppCompatActivity` (`androidx.fragment.app.*`), and performs a direct cast:

```auto
// What the crashing code is doing:
FragmentActivity fragmentActivity = (FragmentActivity) activity;

```

1. `AuthenticationActivity` is a plain `android.app.Activity`:  
The Auth0 Android SDK (underneath `auth0_flutter: 1.14.0`) launches `com.auth0.android.provider.AuthenticationActivity` to manage the Custom Tabs redirect. To keep the SDK minimal and avoid forcing AndroidX dependencies onto consumers, `AuthenticationActivity` extends the standard `android.app.Activity`, **not** `androidx.fragment.app.FragmentActivity`.

When the user taps login, `AuthenticationActivity` is launched, Android fires `dispatchActivityCreated`, the callback attempts to cast it to `androidx.fragment.app.*`, and the runtime throws `ClassCastException`.

## [Solution]

#### **1. Identify Which Library / Code Registers the Callback**

The obfuscated package `L5` usually belongs to one of the following:

- **Analytics / Crash Reporting / Session Replay SDKs** (e.g., UXCam, Datadog, Dynatrace, Smartlook, New Relic, FullStory, or Firebase Performance/In-App Messaging).

- **Flutter Plugins** that hook into Android activity lifecycles to attach fragment listeners.

- **Custom Code** in your Android native wrapper (`MainApplication.kt` / `MainApplication.java`).

Check your `app/build.gradle` and native Android code for any `registerActivityLifecycleCallbacks(...)` calls or auto-initialised monitoring libraries.

#### **2. Apply Safe Type-Checking**

If the code is in your codebase or an internal plugin, ensure the callback checks whether the `activity` is an instance of `FragmentActivity` before casting:

```auto
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
    // DO NOT do: val fragmentActivity = activity as FragmentActivity
    
    // SAFE:
    if (activity is FragmentActivity) {
        // Proceed with FragmentManager / Fragment-specific logic
    }
}

```

Or explicitly exclude Auth0’s activity:

```auto
if (activity is AuthenticationActivity) {
    return
}

```

#### **3. If It Comes from a Third-Party Dependency / Plugin**

- Check if there is an **updated version** of the offending dependency or Flutter plugin where this bug has been patched.

- If the library configuration allows specifying ignored activities, add `com.auth0.android.provider.AuthenticationActivity` to its exclusion list.

* * *

### **Regarding the Subsequent Logs**

In the log output:

`The user closed the browser app and the authentication was canceled.`

Once `AuthenticationActivity` crashes inside `onCreate`, Android aborts the launch transaction and returns focus back to your main task without completing the Custom Tab flow, causing Auth0 Flutter to catch and report that the authentication session was canceled. Fixing the `ClassCastException` will resolve the cancellation error.

Kind Regards,  
Nik
