Webview活动崩溃

时间:2018-09-20 09:30:09

标签: android android-webview

我有一个activity,其中显示了webview和其他views。当我开始此活动时,webview加载就很好,但是当我按下“后退”按钮并退出activity时,应用程序崩溃并显示以下日志。

A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 11620 (RenderThread)

注意-这仅在huawei,moto ...这样的设备上发生

此错误的原因是什么?

如何解决此错误?

XML代码-

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/flashCardScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/flash_card_parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff">


        <FrameLayout
            android:id="@+id/fact_IV"
            android:layout_width="match_parent"
            android:layout_height="220dp"
            android:background="@drawable/curved_flashcard"
            android:transitionName="fact_IV_full">


            <ImageView
                android:id="@+id/flash_card_IV"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:scaleType="centerCrop"
                android:src="@drawable/dummy_image" />


            <ImageView
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_gravity="bottom|end"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="30dp"
                android:src="@drawable/bookmark" />

             <com.google.android.youtube.player.YouTubePlayerView
                 android:id="@+id/player"
                 android:layout_width="match_parent"
                 android:layout_height="200dp"/>


        </FrameLayout>

        <TextView
            android:id="@+id/category_TV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/fact_IV"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:fontFamily="@font/robotoregular"
            android:letterSpacing="0.1"
            android:text="Category"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/short_description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/category_TV"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:fontFamily="@font/robotoregular"
            android:text="Where does it come from?"
            android:textColor="#000"
            android:textSize="15sp" />

        <TextView
            android:id="@+id/long_description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/short_description"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:fontFamily="@font/robotoregular"
            android:lineSpacingExtra="5dp"
            android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
            android:textColor="#515151"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/dateTime_TV"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/long_description"
            android:layout_gravity="bottom"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:fontFamily="@font/robotoregular"
            android:text="Name : August 18, 2018 13:00 IST"
            android:textSize="10sp" />


        <RelativeLayout
            android:id="@+id/webViewContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:layout_below="@id/dateTime_TV">

            <LinearLayout
                android:id="@+id/readMoreFull"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="30dp"
                    android:fontFamily="@font/robotoregular"
                    android:text="Full Story"
                    android:textColor="#000" />

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_marginTop="10dp"
                    android:background="@color/logoColor" />

            </LinearLayout>

            <WebView
                android:id="@+id/flash_card_WV"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="70dp" />


            <ProgressBar
                android:id="@+id/webViewLoadingProgress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true" />


        </RelativeLayout>

    </RelativeLayout>


</ScrollView>

Java代码-

htmlWebView.loadUrl(flashCardObject.getLink());
htmlWebView.setWebViewClient(new WebViewClient() {

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

        @Override
        public void onPageFinished(WebView view, String url) {

            webViewLoadingProgress.setVisibility(View.GONE);
        }
    });


    htmlWebView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

1 个答案:

答案 0 :(得分:0)

尝试检查您在Java代码中使用的布局视图的ID。

Fatal signal 6 (SIGABRT), code -6 in tid 11620 (RenderThread)

主要在您在Java代码中使用了错误的ID时发生。

相关问题