Anamorphosee / stacktrace-decoroutinator

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

Unable to build (on Android projects with minSdk lower than 26 I guess) #38

Open DatL4g opened 1 month ago

DatL4g commented 1 month ago

When applying the plugin (2.4.5), I can't build my app with the following error:

MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26): Ldev/datlag/mimasu/tmdb/api/_CreditsImpl;details(Ldev/reformator/stacktracedecoroutinator/provider/DecoroutinatorSpec;Ljava/lang/Object;)Ljava/lang/Object;

This does not only happen to my "personal" code, but to libraries like lifecycle as well.

Anamorphosee commented 1 month ago

Hi, @DatL4g Unfortunately, Decoroutinator works only on Android SDK level 26 or higher. Because it requires MethodHandle API which is available only from this version.

DatL4g commented 1 month ago

Is it possible to only apply this to Android 26+ and keep the "normal" exception on lower versions. Or is it possible to use Java reflection with invoke() instead?

Anamorphosee commented 1 month ago

Is it possible to only apply this to Android 26+ and keep the "normal" exception on lower versions.

right now there is no such option, but I'll think and maybe can do it in the future.

Or is it possible to use Java reflection with invoke() instead?

Also right now it's not possible. And this option is not a priority because Java reflection makes additional frames unlike MethodHandles

Upd: although using Java reflection for old Android versions is a good idea. And I'll consider implementing it in the next release.

nordfalk commented 1 month ago

I would also be very happy if this library didnt force me to upgrade from API 23 to API26.

There are not many users.... but Im reluctant to exclude them "just" to get better stack traces.

So, it would be great if SD allowed lower Android versions, but just didnt do anything at all on these lower SDK versions.

I have no need of getting better stack traces for these old versions, so dont bother adding new complexity, such as fallback on reflection. Just let us compile and and we are happy :-)

nordfalk commented 1 month ago

The old Android phones are already slow. I would prefer to not have anything, such as reflection, that makes my app slower on older phones.