Webview崩溃并显示简单的HTML并抛出JNI错误

问题描述 投票:0回答:1

嗨,我尝试加载一个webview,但我不知道为什么有些HTML会使应用程序崩溃,而上述日志。我不得不说html真的很简单

<style type="text/css">
    body {
        font-size: 14;
        text-align: justify;
        max-width: 100%;
        word-break: break-all;
        word-break: break-word
    }
    
    img {
        display: inline;
        height: auto;
        max-width: 100%;
    }
    
    iframe {
        display: inline;
        height: auto;
        max-width: 100%;
    }
</style>
<html>

<body>
    <p align="justify" line-height="1.5">
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">[ TxxxxY]&nbsp;</font></span></p>
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">xxxx,&nbsp;</font></span></p>
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">xxxxy.&nbsp;</font></span></p>
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">* xxxxxx9.&nbsp;</font></span></p>
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">*xxxxxxố 5&nbsp;</font></span></p>
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">xxxxxxxxxxxxxxxxx!</font></span></p>
        <p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3"><br></font></span></p>
    </p>
</body>

</html>

和加载weview方法

   if (Build.VERSION.SDK_INT >= 19) {
            webView.setLayerType(webView.isHardwareAccelerated() ? View.LAYER_TYPE_HARDWARE : 
           View.LAYER_TYPE_NONE, null);
        } else {
            webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }

webView.loadDataWithBaseURL(“”,html,“ text / html; charset = utf-8”,“ utf-8”,“”);

我认为它看起来像有关JNI的东西,所以请对此提出任何建议

android webview hardware-acceleration
1个回答
0
投票

不确定JNI错误,但是我使用这种方法尝试了html,并且效果很好。

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_webview)
    web.settings.javaScriptEnabled = true
    web.loadUrl("file:///android_asset/myhtml.html");
}

可以尝试在其他仿真器或设备上运行。可能是特定于模拟器的问题

© www.soinside.com 2019 - 2024. All rights reserved.