I have a simple WebView
where JavaScript is enabled and WebChromeClient
is used. A web content that I am loading has a select
tag. When I click on it, the app crashes with following snippet of error:
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1351)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2774)
at android.content.res.Resources.getLayout(Resources.java:1165)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:378)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:369)
at org.chromium.content.browser.input.SelectPopupAdapter.getView(SelectPopupAdapter.java:56)
I found this material, but it didn't help and I couldn't find any solution for this problem. As far as I know, the app is crashed on Android 5 and 6 only. When select
tag of HTML is pressed, it seems that Android tries to show its own Spinner
. It uses Resources
that causes the error somehow. I tried to create WebView
progmatically, but it didn't help. Here is my code:
val webview = WebView(this)
webview.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)
rootLayout.addView(webview)
webview.webChromeClient = WebChromeClient()
webview.settings.javaScriptEnabled = true
webview.loadUrl(intent.getStringExtra(URL))
From libraries of Google, I use following:
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
My question is how to avoid this error? Maybe we can create custom WebView
?