Skip to content

Conversation

@benoitletondor
Copy link

This prevents a crash with appcompat 1.1.0.

Exception thrown:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ***, PID: 5575
    java.lang.RuntimeException: Unable to destroy activity {***/***.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4458)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4476)
        at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:4760)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4693)
        at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:55)
        at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:4743)
        at android.app.ActivityThread.access$3200(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1818)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference
        at androidx.fragment.app.Fragment.performDetach(Fragment.java:2844)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1033)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1237)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1302)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2655)
        at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2640)
        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:233)
        at ***.MainActivity.onDestroy(MainActivity.kt:376)
        at android.app.Activity.performDestroy(Activity.java:7395)
        at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1306)
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4443)

Associated google tracker issue: https://issuetracker.google.com/issues/135764330

@kevintorch
Copy link

kevintorch commented Jul 15, 2019

im having the same issue with androidX...please help

@benoitletondor
Copy link
Author

@kevintorch I ended up forking the repo and applied the exact same fix as in the PR and it works. You can do the same before it's merged ;)

@Protino
Copy link

Protino commented Aug 12, 2019

@benoitletondor Can you please guide on how to include these changes by forking the library. Should I import this as a module? (Will I have to migrate this module to androidX too?)

@benoitletondor
Copy link
Author

@Protino that's exactly what I did. Migrating it to androidX only took a few minutes, it's not complicated

@vpotvin
Copy link

vpotvin commented Nov 5, 2019

For anyone looking for this fix without the trouble of doing it manually, I've released it here as a separate library: https://github.com/vpotvin/CaldroidX since this original library has not seen an update in 4 years.

@SophieSagot
Copy link

Wonderful, I was blocked that bug since 2 two days. Changing the dependencies made immediately every things work perfectly !!! Thank you for all.

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

Successfully merging this pull request may close these issues.

8 participants