```AndroidView(view = webview(ctx, "test"))``` Fac...
# compose
c
Copy code
AndroidView(view = webview(ctx, "test"))
Facing crash in Huawei device while using AndroidView for converting ClassicView to compose. It is working in emulator and samsung device
Copy code
fun webview(ctx: Context, html: String) = WebView(ctx).apply {
    Log.d("ChanLog", "webview: $html")
    this.webViewClient = WebViewClient()
    loadData("<html><body><h1>Ch($html)</h1></body></html>", "text/html", "utf-8")
}
Copy code
at androidx.ui.core.AndroidViewsHandler.onDescendantInvalidated(AndroidViewsHandler.kt:40)
    at android.view.HwApsImpl.isNonEmptyFrameCase(HwApsImpl.java:353)
    at android.view.ViewGroup.invalidateChild(ViewGroup.java:5984)
    at android.view.View.invalidateInternal(View.java:17751)
    at android.view.View.invalidate(View.java:17702)
    at android.view.View.setFrame(View.java:22267)
    at android.webkit.WebView.access$701(WebView.java:107)
m
Could you please file a bug about this issue?
a
you also need to wrap your webView into
remember
.
AndroidView(view = remember { webview(ctx, "test") })
so the view is not recreated everytime this function is recomposed
👍 1
c
@Andrey Kulikov still facing the error. Let me file the issue
a
and could you please paste the full error stacktrace. in the current one I don't see what is the throwable, seems like the first line is removed
c
Though attached it
Copy code
--------- beginning of crash
2020-07-08 18:35:49.258 22741-22741/com.chan.composetryout E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.chan.composetryout, PID: 22741
    java.lang.NullPointerException
        at androidx.ui.core.AndroidViewsHandler.onDescendantInvalidated(AndroidViewsHandler.kt:40)
        at android.view.HwApsImpl.isNonEmptyFrameCase(HwApsImpl.java:353)
        at android.view.ViewGroup.invalidateChild(ViewGroup.java:5984)
        at android.view.View.invalidateInternal(View.java:17751)
        at android.view.View.invalidate(View.java:17702)
        at android.view.View.setFrame(View.java:22267)
        at android.webkit.WebView.access$701(WebView.java:107)
a
by the way, what compose version do you use? I think we fixed something similar in dev14
c
I am using this
Copy code
def compose_version =  "0.1.0-dev14"
a
ok, maybe something different then. please file a bug!
👍 1
c