webview冻结在android 4.4.2中

时间:2017-06-30 13:46:05

标签: android html android-webview

我有一个应用程序,我正在使用url加载活动中的webview 还有抽屉 这是在android 4.4.2中冻结 ,那在Android 5.0和6.0以后工作正常

根据android监视器登录冻结情况如下 ,那个日志在每个swype上重复或触摸

  • I / View:触发调度到android.webkit.WebView {42841ec0 VFED..C。 .F ...... 0,0-480,666#7f100075 app:id / web_view},event = MotionEvent {action = ACTION_DOWN,id [0] = 0,x [0] = 248.48233, y [0] = 327.48773,toolType [0] = TOOL_TYPE_FINGER,buttonState = 0, metaState = 0,flags = 0x0,edgeFlags = 0x0,pointerCount = 1,historySize = 0, eventTime = 20907060,downTime = 20907060,deviceId = 3,source = 0x1002}
    • D / VelocityTracker:无法打开'/ dev / touch'(权限被拒绝)
    • D / VelocityTracker:tpd读取x失败:文件号错误
    • D / VelocityTracker:tpd读取失败:文件号错误
    • I / View:触发调度到android.webkit.WebView {42841ec0 VFED..C。 .F ...... 0,0-480,666#7f100075 app:id / web_view},event = MotionEvent { action = ACTION_UP,id [0] = 0,x [0] = 248.48233,y [0] = 327.48773, toolType [0] = TOOL_TYPE_FINGER,buttonState = 0,metaState = 0,flags = 0x0, edgeFlags = 0x0,pointerCount = 1,historySize = 0,eventTime = 20907129, downTime = 20907060,deviceId = 3,source = 0x1002}

我将webview属性设置为

webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);
    webView.getSettings().setGeolocationEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setAllowFileAccess(true);

我设置了webclient

webView.setWebChromeClient(new WebChromeClient() {            

@覆盖             public boolean onShowFileChooser(WebView webView,ValueCallback filePathCallback,FileChooserParams fileChooserParams){                 返回true;             }             @覆盖             public void onGeolocationPermissionsShowPrompt(String origin,GeolocationPermissions.Callback callback)             {                 callback.invoke(origin,true,false);             }             //适用于Android 3.0+的openFileChooser             public void openFileChooser(ValueCallback uploadMsg,String acceptType){            }             //适用于Android的openFileChooser< 3.0             public void openFileChooser(ValueCallback uploadMsg){             }             // openFileChooser用于其他Android版本             public void openFileChooser(ValueCallback uploadMsg,                                         字符串acceptType,                                         字符串捕获){                 openFileChooser(uploadMsg,acceptType);             }             public boolean onConsoleMessage(ConsoleMessage cm){              onConsoleMessage(cm.message(),cm.lineNumber(),cm.sourceId());                 返回true;             }             public void onConsoleMessage(String message,int lineNumber,String sourceID){             }         }); //结束setWebChromeClient

    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return true;
        }
        @Override

        public void onPageFinished(WebView view, final String url) {

            super.onPageFinished(view, url);
            CookieSyncManager.getInstance().sync();
            Log.i("finished", url);
        }
    });

这是我的xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layMain"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    tools:context=".LandingActivity">

    <WebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/include"
        android:scrollbarStyle="insideOverlay"
        android:scrollbars="none"
        android:visibility="gone" />
    <ImageView
        android:id="@+id/splash"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/splash"
        android:visibility="gone" />
    <include
        android:id="@+id/include"
        layout="@layout/bottom_option"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
    <FrameLayout
        android:id="@+id/framLay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">
    </FrameLayout>
</RelativeLayout>
<LinearLayout
    android:layout_width="300dp"
    android:layout_height="fill_parent"
    android:layout_gravity="end"
    android:background="@color/white"
    android:orientation="vertical">
    <ListView
        android:id="@+id/navdrawer"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:background="@android:color/white"
        android:choiceMode="singleChoice"
        android:drawSelectorOnTop="false"></ListView>
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_marginBottom="2dp"
        android:layout_marginTop="2dp"
        android:background="#454545" />
    <ListView
        android:id="@+id/navdrawer2"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:layout_weight="1"
        android:background="@android:color/white"
        android:choiceMode="singleChoice"
        android:drawSelectorOnTop="false"></ListView>
    <TextView
        android:id="@+id/tvVersion"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="1dp"
        android:gravity="center" />
    <include layout="@layout/listview_bottom" />
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

Gradle with 3.0.0及以上版本和compileSdkVersion 26导致此问题......

我的解决方案不是确切的解决方案,但它解决了问题... 切换应用程序gradle到

classpath 'com.android.tools.build:gradle:2.3.0'

将模块切换到

compileSdkVersion 25
buildToolsVersion '25.0.2'

将所有其他api更改为最大25将解决frezee问题..直到主解决方案到来,值得改变这些事情!

似乎&#34; Kotlin&#34;不是预期的...导致更多的CPU工作