Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k views
in Technique[技术] by (71.8m points)

dependencies - com.android.tools.r8.a: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)

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

  1. if I remove dependencies it works fine.

  2. 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.

question from:https://stackoverflow.com/questions/65842742/com-android-tools-r8-a-methodhandle-invoke-and-methodhandle-invokeexact-are-onl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...