Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on activity finish #35

Open
rubenhorn opened this issue Dec 16, 2019 · 0 comments
Open

Crash on activity finish #35

rubenhorn opened this issue Dec 16, 2019 · 0 comments

Comments

@rubenhorn
Copy link
Contributor

After adding a BlurredView, my App crashes when I go to another screen.
Note that I don't call blurView.blurredView(View) yet.

The layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false">
        <!-- my layout -->      
    <com.ms_square.etsyblur.BlurringView
        android:id="@+id/blurView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

The fragment:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    // ...
    blurView.blurConfig(myBlurConfig)
}

The stack trace:

2019-12-16 16:59:39.216 21890-21890/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.myapp, PID: 21890
    java.lang.RuntimeException: Unable to destroy activity {com.myapp.BlurActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewTreeObserver android.view.View.getViewTreeObserver()' on a null object reference
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4707)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4730)
        at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1947)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7037)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewTreeObserver android.view.View.getViewTreeObserver()' on a null object reference
        at com.ms_square.etsyblur.BlurringView.onDetachedFromWindow(BlurringView.java:105)
        at android.view.View.dispatchDetachedFromWindow(View.java:20067)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3987)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5588)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5559)
        at android.view.ViewGroup.removeView(ViewGroup.java:5490)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:973)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
        at androidx.fragment.app.FragmentManagerImpl.dispatchDestroyView(FragmentManagerImpl.java:2638)
        at androidx.fragment.app.Fragment.performDestroyView(Fragment.java:2805)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:954)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
        at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644)
        at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329)
        at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366)
        at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:210)
        at android.app.Activity.performDestroy(Activity.java:7681)
        at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1306)
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4692)

The source:

if (this.blurredView.getViewTreeObserver().isAlive()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant