-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal Exception: java.lang.IllegalStateException - com.google.android.gms.dynamite.DynamiteModule$LoadingException: Remote load failed. No local fallback found. #109
Comments
@mohsenoid does your device have "Google Play Services" installed? |
It is a user device, which I believe it doesn't or has some old or broken Google Play Services version, but shouldn't the button somehow handle it? What I did for the moment was copy the button source code and add a fallback UI solution just in case there was a crash in initialization till we get a proper fix for this thread: @Composable
fun GooglePayButton(
onClick: () -> Unit,
allowedPaymentMethods: String,
modifier: Modifier = Modifier,
theme: GooglePayButtonTheme = GooglePayButtonTheme.Dark,
type: GooglePayButtonType = GooglePayButtonType.Buy,
radius: Dp = 100.dp,
enabled: Boolean = true,
onError: (Exception) -> Unit = {},
fallbackUi: @Composable (() -> Unit)? = null,
) {
var showFallback by remember { mutableStateOf(false) }
val radiusPixelValue = with(LocalDensity.current) { radius.toPx().toInt() }
if (!showFallback) {
AndroidView(
modifier = modifier,
factory = { context ->
val payButton = PayButton(context)
try {
payButton.initialize(
ButtonOptions.newBuilder()
.setButtonTheme(theme.value)
.setButtonType(type.value)
.setCornerRadius(radiusPixelValue)
.setAllowedPaymentMethods(allowedPaymentMethods)
.build()
)
} catch (e: Exception) {
onError(e)
showFallback = true
}
payButton
},
update = { button ->
if (!showFallback) {
button.apply {
alpha = if (enabled) FULL_ALPHA else HALF_ALPHA
isEnabled = enabled
if (enabled) {
setOnClickListener { onClick() }
} else {
setOnClickListener(null)
}
}
}
}
)
} else {
fallbackUi?.invoke()
}
} Such crashes where two worlds of View UI and Compose UI collide are hard to catch since we don't have try/catch in a compose function. |
Thanks @mohsenoid However, I can see we could improve our handling for those cases. I will look into this! |
@mohsenoid do you want to submit a PR with your fallback UI solution? |
Sure if you believe it is a decent and acceptable solution 👍 |
Done, open for review #113 |
…ptions [#109] Handle potential init exceptions and fallback
We are using this library v1.0.0 to show the GooglePay button, but during
GmsPayButton
initialization this exception happens and we cannot catch it in the compose UI.Device: OnePlus 11 5G
OS version: android 14
Here is the full stack trace:
The text was updated successfully, but these errors were encountered: