implementation 'org.apache.poi:poi:5.0.0'
above dependencies work fine when I run on the emulator/phone using Run 'app' but when I try to build apk then I got the below error.
com.android.tools.r8.a: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
I try below
if I remove dependencies it works fine.
if I update minSdkVersion 21 to 26 then it works fine.
so my problem is I want to use minsdkversion 21 and also that dependency(this feature(EXCEL FILE) only available to sdkversion>=26)
so how can I achieve the same?
THANK YOU IN ADVANCE.
Right now this is not possible. D8 will only allow compiling code which use invoke-custom and method handles for a minSdkVersion
of 26 or higher, as that is the first version where these features are supported by Android.
There is an open issue on lifting that restriction. However, depending on the code in the library this might just end up as a runtime error if the code using invoke-custom and method handles will be hit at runtime on a device with API level of 25 or below.
The reason you can run you code from Android Studio, is that when debugging on a device or emulator, Android Studio will "artificially" raise the minSdkVersion
for the build to that of the device or emulator attached. This is to provide the best development experience by taking advantage of what the device or emulator supports.