# \[Archive\] App crash on login

**URL:** <https://builder.metamask.io/t/archive-app-crash-on-login/1287>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [July 30, 2024, 11:41am UTC](https://builder.metamask.io/t/archive-app-crash-on-login/1287 "2024-07-30T11:41:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danil.makarenko](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@danil.makarenko](https://builder.metamask.io/u/danil.makarenko)\
**Post date:** [July 30, 2024, 11:41am UTC](https://builder.metamask.io/t/archive-app-crash-on-login/1287/1 "2024-07-30T11:41:48Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **danil.makarenko** on 7/30/2024.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

- SDK Version: 8.0.1
- Platform: Android

Some of our users are facing app crashes when logging in.  
I am not sure whether it’s related to the device or not, but most of the users have no problems

Here is the email of one of the affected users.  
[tiagocappelle@gmail.com](mailto:tiagocappelle@gmail.com)

The crash comes from PnP SDK

```auto
          Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String j7.a.getString(java.lang.String, java.lang.String)' on a null object reference
       at com.web3auth.session_manager_android.keystore.KeyStoreManager.getPreferencesData(KeyStoreManager.java:134)
       at com.web3auth.session_manager_android.SessionManager.authorizeSession(SessionManager.kt:138)
       at com.web3auth.core.Web3Auth.authorizeSession(Web3Auth.kt:335)
       at com.web3auth.core.Web3Auth.initialize(Web3Auth.kt:170)
       at com.app.renegade.ui.home.HomeBaseActivity.login(HomeBaseActivity.kt:258)
       at com.app.renegade.ui.vault.custom_web3auth.CustomWalletRouteKt$CustomWalletScreen$2.invokeSuspend(CustomWalletRoute.kt:114)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
       at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
       at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
       at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
       at android.os.Handler.handleCallback(Handler.java:958)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

```

---

<div class="post-metadata">

**Author:** ![Ayush](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/ayush/32/1540_2.png) [@Ayush](https://builder.metamask.io/u/Ayush)\
**Post date:** [July 31, 2024, 2:11am UTC](https://builder.metamask.io/t/archive-app-crash-on-login/1287/2 "2024-07-31T02:11:24Z")

</div>

Looks like the storage has been deleted, and we can’t find any active session. Please tell them to logout if they can and re-login if they can. The other option would be to deleted the app, and install again but please make sure user has enabled the MFA option, otherwise they will lose access to their account.

Also, can you share your initalize code?

---

<div class="post-metadata">

**Author:** ![danil.makarenko](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@danil.makarenko](https://builder.metamask.io/u/danil.makarenko)\
**Post date:** [July 31, 2024, 10:15am UTC](https://builder.metamask.io/t/archive-app-crash-on-login/1287/3 "2024-07-31T10:15:41Z")

</div>

```auto
private fun initWeb3Auth() {
        web3Auth = Web3Auth(
            Web3AuthOptions(
                context = this@HomeBaseActivity,
                clientId = BuildConfig.WEB3AUTH_CLIENT_ID,
                network = if (BuildConfig.FLAVOR == "dev") Network.SAPPHIRE_DEVNET else Network.SAPPHIRE_MAINNET,
                redirectUrl = Uri.parse("${BuildConfig.APPLICATION_ID}://auth"), // your app's redirect URL,
                loginConfig = hashMapOf(
                    "jwt" to LoginConfigItem(
                        verifier = BuildConfig.WALLET_VERIFIER_NAME,
                        typeOfLogin = TypeOfLogin.JWT,
                        clientId = BuildConfig.WEB3AUTH_CLIENT_ID
                    )
                )
            )
        )
    }

override fun login(
        token: String,
        onSuccess: (response: Web3AuthResponse) -> Unit,
        onError: (throwable: Throwable) -> Unit
    ) {
        val sessionResponse: CompletableFuture<Void> = web3Auth.initialize()
        sessionResponse.whenComplete { _, error ->
            if (error == null) {
                try {
                    // User is already logged in
                    web3Auth.getWeb3AuthResponse()?.let { onSuccess(it) }
                } catch (e: Throwable) {
                    // during the session check, the user info will not be available, so we need to login
                    signIn(
                        token = token,
                        onLoginSuccess = onSuccess,
                        onLoginFailed = onError
                    )
                }
            } else {
                signIn(
                    token = token,
                    onLoginSuccess = onSuccess,
                    onLoginFailed = onError
                )
            }
        }
    }

private fun signIn(
        token: String,
        onLoginSuccess: (Web3AuthResponse) -> Unit,
        onLoginFailed: (throwable: Throwable) -> Unit,
    ) {
        val loginCompletableFuture = web3Auth.login(
            LoginParams(
                Provider.JWT,
                extraLoginOptions = ExtraLoginOptions(id_token = token),
                mfaLevel = MFALevel.MANDATORY
            )
        )

        loginCompletableFuture.whenComplete { loginResponse, error ->
            if (error == null) {
                onLoginSuccess(loginResponse)
            } else {
                Timber.e(error)
                onLoginFailed(error)
            }
        }
    }

```

---

<div class="post-metadata">

**Author:** ![Ayush](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/ayush/32/1540_2.png) [@Ayush](https://builder.metamask.io/u/Ayush)\
**Post date:** [August 2, 2024, 2:45am UTC](https://builder.metamask.io/t/archive-app-crash-on-login/1287/4 "2024-08-02T02:45:26Z")

</div>

I don’t see any issue in the code that could trigger that, can you relay the above steps to user and ask if it works? If it doesn’t work, please get the user’s device details to debug the issue.
