diff --git a/app/src/main/java/com/flowfoundation/wallet/page/common/WebViewActivity.kt b/app/src/main/java/com/flowfoundation/wallet/page/common/WebViewActivity.kt index d0379cc91..8dad64d52 100644 --- a/app/src/main/java/com/flowfoundation/wallet/page/common/WebViewActivity.kt +++ b/app/src/main/java/com/flowfoundation/wallet/page/common/WebViewActivity.kt @@ -3,10 +3,14 @@ package com.flowfoundation.wallet.page.common import android.content.Context import android.content.Intent import android.os.Bundle +import android.util.AndroidRuntimeException import android.view.MenuItem +import android.widget.Toast import com.flowfoundation.wallet.R import com.flowfoundation.wallet.base.activity.BaseActivity import com.flowfoundation.wallet.page.browser.widgets.LilicoWebView +import com.flowfoundation.wallet.utils.loge +import com.flowfoundation.wallet.utils.toast class WebViewActivity : BaseActivity() { @@ -14,9 +18,24 @@ class WebViewActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_webview) - findViewById(R.id.webview).apply { - loadUrl(this@WebViewActivity.url!!) + // Inflating the WebView can throw AndroidRuntimeException wrapping + // WebViewFactory$MissingWebViewPackageException on devices where the + // Android System WebView package is missing, disabled, or being updated. + // Crashing the activity in that case (issue #1256) leaves the user + // with no recourse. Catch it, surface a clear message and finish. + try { + setContentView(R.layout.activity_webview) + findViewById(R.id.webview).apply { + loadUrl(this@WebViewActivity.url!!) + } + } catch (e: AndroidRuntimeException) { + loge(e) + toast(R.string.webview_unavailable, Toast.LENGTH_LONG) + finish() + } catch (e: Exception) { + loge(e) + toast(R.string.webview_unavailable, Toast.LENGTH_LONG) + finish() } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 372bebd54..987f8b61e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -830,4 +830,5 @@ You have copied an EVM address on the Flow network, please make sure you only send assets on the Flow network to this address otherwise they will be lost. EVM on Flow address Recover profile + Android System WebView is unavailable on this device. Please install or enable it from the Play Store and try again.