NoSuchMethodError: No virtual method decrementAndGet

NoSuchMethodError: No virtual method decrementAndGet

一些 设备上我的应用崩溃

Exception java.lang.NoSuchMethodError: No virtual method decrementAndGet()I in class Lorg/apache/commons/lang3/mutable/MutableInt; or its super classes (declaration of 'org.apache.commons.lang3.mutable.MutableInt' appears in /system/framework/framework.jar:classes2.dex)

据我所知(我可能错了),Android 设备已经有 apache commons lang3 库。

我也将它包含在我的应用程序中(作为依赖项),但似乎实际加载到类路径上的不是我提供的那个,而是一个不存在该方法的旧版本。

有没有办法指示 gradle 强制使用我的 apk 中定义的 apache commons lang3 版本,而不是系统?

From what I know (I may be wrong), Android devices already have the apache commons lang3 library

如果是,则没有记录。也可能是 only certain device manufacturers are loading it in the zygote(所有 Android SDK 应用程序的进程都从该进程派生),而在其他制造商的其他设备上则不是问题。

it seems the one actually loaded on the classpath is not the one I provided but an older version where that method doesn't exist

应用程序无法覆盖 zygote 中的内容。合子永远赢。

Is there a way to instruct gradle to force usage of the apache commons lang3 version defined in my apk instead of the one provided by the system?

不,对不起。我建议不要使用该库。