更新支持库后Android底层崩溃

时间:2017-10-09 09:08:10

标签: android android-support-library bottom-sheet

我们有一个底页,在将支持库版本更新为'26 .0.1'后,当您打开应用程序时,在显示底部工作表之前,该应用程序已崩溃。

<android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/vf_ovelay_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone" />

        <FrameLayout
            android:id="@+id/bottom_sheet_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="32dp"
            android:clickable="true"
            android:visibility="gone"
            tools:visibility="visible"
            app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
            app:behavior_skipCollapsed="true"/>

</android.support.design.widget.CoordinatorLayout>

private BottomSheetBehavior mBottomSheetBehavior;
private ViewGroup bottomSheet;

以下是我展示的方式

mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
mBottomSheetBehavior.setHideable(true);//Important to add
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
bottomSheet.removeAllViews();
bottomSheet.setVisibility(VISIBLE);
bottomSheet.addView(getCustomView());

当我点击屏幕时,应用程序崩溃了!

,日志是

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference
at android.support.design.widget.BottomSheetBehavior.onInterceptTouchEvent(BottomSheetBehavior.java:299)
at android.support.design.widget.CoordinatorLayout.performIntercept(CoordinatorLayout.java:460)
at android.support.design.widget.CoordinatorLayout.onInterceptTouchEvent(CoordinatorLayout.java:499)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2310)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2371)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2371)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2371)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2371)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2371)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2371)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2568)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1776)
at android.app.Activity.dispatchTouchEvent(Activity.java:2866)

1 个答案:

答案 0 :(得分:0)