代码之家  ›  专栏  ›  技术社区  ›  Rektirino

WebView崩溃的活动

  •  0
  • Rektirino  · 技术社区  · 6 年前

    我有一个 activity 那表明 webview 以及其他 views . 当我开始这个活动时 WebVIEW 负载很好,但当我按下后退按钮并退出 活动 ,应用程序将使用以下日志崩溃。

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

    注意-这只发生在一些设备上,如华为,摩托罗拉…

    这个错误的原因是什么?

    如何修复此错误?

    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 回复  |  直到 6 年前
        1
  •  0
  •   Akash Mishra    6 年前

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

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

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