Android – java.lang.illegalargumentexception: for kotlin and WebView, the parameter specified as non null is null

I tried to populate my WebView with a custom HTML string and try to show progress when not loaded and hide it when finished

This is my code:

webView.settings.javaScriptEnabled = true
webView.loadDataWithBaseURL(null, presentation.content, "text/html", "utf-8", null)

webView.webViewClient = object : WebViewClient() {

  override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
    super.onPageStarted(view, url, favicon)
    webViewProgressBar.visibility = ProgressBar.VISIBLE
    webView.visibility = View.INVISIBLE
  }

  override fun onPageCommitVisible(view: WebView, url: String) {
    super.onPageCommitVisible(view, url)
    webViewProgressBar.visibility = ProgressBar.GONE
    webView.visibility = View.VISIBLE
  }
}

I received this error, which is not pointing to any line of my code:

                                                                             java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter favicon
                                                                                 at com.hidglobal.tmt.app.mobiBadge.ui.presentation.PresentationActivity$showPresentation$1.onPageStarted(PresentationActivity.kt)
                                                                                 at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:215)
                                                                                 at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:20)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:148)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5443)
                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

resolvent:

The problem is that the onpagestarted method is called (by the system) to pass the null value of the favicon parameter. This may happen when there are some kotlin code that interoperates with java code (by default, you should get an object that can be null)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>