问题描述
我有一个在Android Studio或Gradle中进行构建时已开始引发此错误的项目:
I have a project that has started throwing this error when building in Android Studio or Gradle:
com.android.tools.r8.ApiLevelException: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
现在,我认为它与Java 8功能(也许是lambda)的使用有关,但是错误消息没有提供问题根源的线索-可能是我的代码,也可能是库.
Now I assume that it's related to use of Java 8 features, perhaps a lambda, but the error message gives no clue as to where the problem lies - it could be my code or it could be a library.
找出有问题的代码在哪里的最佳方法是什么?这是一个相当大的应用程序,具有多个模块和相当多的库.
What's the best way to find out where the offending code is? It's a reasonably large app with several modules and quite a few libraries.
推荐答案
在我的情况下,我尝试在运行Api版本26或更高版本的检测测试中通过模仿来模拟某些东西,只要以下问题,删除依赖项是我唯一的解决方案无法解析: https://github.com/mockk/mockk/issues/281
In my case i tried to mock something via mockk in an instrumentation test running Api Version 26 or higher, removing the dependency was my only solution as long as following issue is not resolved: https://github.com/mockk/mockk/issues/281
更新:看来问题已解决,使用模拟版本1.10.0可以解决此问题
Update: It seems that the issue got resolved and using mockk version 1.10.0 will resolve this issue
这篇关于解密时如何查找错误原因:MethodHandle.invoke和MethodHandle.invokeExact的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!