java.lang.IllegalArgumentException: Parameter specified as non-null is null for Kotlin and WebView

后端 未结 3 822
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 01:09

I am trying to populate my WebView with custom HTML string and trying to show progress when it is not loaded, and hide it when finished.

Here is my code:

<         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 01:53

    I have the same problem.

     java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter favicon
        at com.haoyong.szzc.module.share.view.activity.WebActivity$MyWebViewClient.onPageStarted(WebActivity.kt:0)
        at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:495)
        at com.android.org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:122)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5313)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1116)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:809)
    

    I just do it as follows: change

    override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
                super.onPageStarted(view, url, favicon)
            }
    

    to

     override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
                super.onPageStarted(view, url, favicon)
            }
    

    Because it is not allowed to use the null parameter in the Kotlinlang. just change the Bitmap to Bitmap? Then it will work well. Hope this can help the other people.

提交回复
热议问题