On some devices my app crashes with
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)
From what I know (I may be wrong), Android devices already have the apache commons lang3 library.
I am also including it with my app (as a dependency), but 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.
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?
From what I know (I may be wrong), Android devices already have the apache commons lang3 library
If it is, it is undocumented. It also may be that only certain device manufacturers are loading it in the zygote (the process from which all Android SDK apps' processes are forked), whereas it is not a problem on other devices from other manufacturers.
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
Apps cannot override what is in the zygote. The zygote always wins.
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?
No, sorry. I recommend not using that library.