Anamorphosee / stacktrace-decoroutinator

Small lib for recovering stack trace in exceptions thrown in Kotlin coroutines
Apache License 2.0
158 stars 4 forks source link

java.lang.IllegalStateException: Stacktrace-decoroutinator runtime can not be loaded because BaseContinuationImpl was already loaded. #23

Open kenny-statsig opened 1 year ago

kenny-statsig commented 1 year ago

I am calling DecoroutinatorRuntime.load() at the top of my app's onCreate but it seems to be causing the app to crash I've attached a screenshot of the full stack trace.

Screenshot 2023-06-22 at 1 50 43 PM

Anamorphosee commented 1 year ago

@kenny-statsig It seems you add a call of DecoroutinatorRuntime.load() to the MainActivity's onCreate() method instead of the Application's one. Please see the correct example from the Android tests. https://github.com/Anamorphosee/stacktrace-decoroutinator/blob/master/stacktrace-decoroutinator-android/src/androidTest/AndroidManifest.xml https://github.com/Anamorphosee/stacktrace-decoroutinator/blob/master/stacktrace-decoroutinator-android/src/androidTest/kotlin/utils-test.kt#L31

MarcLFJ commented 12 months ago

I encountered the same issue. I had the .load() setup correctly in our Application class and still ran into this issue. Tried moving it to the init {...}, but same result. We are using dependency injection (Hilt), and some of the injected classes has coroutines in their init(), which might be the issue? 🤔 I did not find a workaround

jhollowayj commented 5 months ago

I first tried using the suggested onCreate, but got that same "BaseContinuationImpl was already loaded" error. I switched to use the init{} block in my Application file and things started working!

I'd bet that having coroutines in your hilt stuff is what's causing the BaseContinuationImpl to be loaded before you'd like. I don't know a solution for you, but wanted to say that your init trick is greatly appreciated!

saket commented 5 months ago

That did the trick, thank you!