-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Some users experience a crash on app startup with the following exception:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx/com.xsolla.android.login.unity.UnityProxyActivity}: java.lang.NullPointerException
Caused by java.lang.NullPointerException:
at com.xsolla.android.login.unity.UnityProxyActivity.onCreate(UnityProxyActivity.kt:20)
In UnityProxyActivity.onCreate(), the code retrieves the social network identifier using:
val socialNetworkString = intent.getStringExtra(ARG_SOCIAL_NETWORK)
val socialNetwork = SocialNetwork.valueOf(socialNetworkString!!)If the Intent used to start UnityProxyActivity does not contain the ARG_SOCIAL_NETWORK extra, getStringExtra() returns null. The subsequent use of the not-null assertion operator (!!) causes a NullPointerException, crashing the app.
This can happen if:
- The activity is launched incorrectly (e.g., from an external source or deep link without required parameters).
- The Android system recreates the activity after process death without properly restoring the original intent.
Environment:
Unity version: 2022.3.62f2
Xsolla Store Unity SDK: v3.0.1
Suggested Fix:
Add null and validity checks before using the social network string:
val socialNetworkString = intent.getStringExtra(ARG_SOCIAL_NETWORK)
if (socialNetworkString == null) {
finish()
return
}
try {
val socialNetwork = SocialNetwork.valueOf(socialNetworkString)
// proceed with auth
} catch (e: IllegalArgumentException) {
finish()
return
}Metadata
Metadata
Assignees
Labels
No labels