New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError: org.apache.commons.lang3.Validate.inclusiveBetween #394

Closed
pperliti opened this Issue Jun 27, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@pperliti

pperliti commented Jun 27, 2016

Hi,
I'm using Android build of FHIR library (hapi-fhir-android v1.4) within an app I developed some months ago. Everything works fine but on some versions of Xiaomi I'm gettting this error:

java.lang.NoSuchMethodError: org.apache.commons.lang3.Validate.inclusiveBetween
at ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition.(BaseRuntimeDeclaredChildDefinition.java:49)
at ca.uhn.fhir.context.BaseRuntimeChildDatatypeDefinition.(BaseRuntimeChildDatatypeDefinition.java:43)
at ca.uhn.fhir.context.RuntimeChildPrimitiveDatatypeDefinition.(RuntimeChildPrimitiveDatatypeDefinition.java:35)
at ca.uhn.fhir.context.ModelScanner.scanCompositeElementForChildren(ModelScanner.java:630)
at ca.uhn.fhir.context.ModelScanner.scanCompositeElementForChildren(ModelScanner.java:399)
at ca.uhn.fhir.context.ModelScanner.scanCompositeDatatype(ModelScanner.java:374)
at ca.uhn.fhir.context.ModelScanner.scan(ModelScanner.java:321)
at ca.uhn.fhir.context.ModelScanner.init(ModelScanner.java:202)
at ca.uhn.fhir.context.ModelScanner.(ModelScanner.java:113)
at ca.uhn.fhir.context.FhirContext.scanResourceTypes(FhirContext.java:431)
at ca.uhn.fhir.context.FhirContext.(FhirContext.java:140)
at ca.uhn.fhir.context.FhirContext.(FhirContext.java:113)
at ca.uhn.fhir.context.FhirContext.forDstu2(FhirContext.java:507)

Another one is:

java.lang.NoSuchMethodError: No static method inclusiveBetween(JJJLjava/lang/String;)V in class Lorg/apache/commons/lang3/Validate; or its super classes (declaration of 'org.apache.commons.lang3.Validate' appears in /system/framework/framework.jar:classes2.dex)
at ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition.(BaseRuntimeDeclaredChildDefinition.java:49)
at ca.uhn.fhir.context.BaseRuntimeChildDatatypeDefinition.(BaseRuntimeChildDatatypeDefinition.java:43)
at ca.uhn.fhir.context.RuntimeChildPrimitiveDatatypeDefinition.(RuntimeChildPrimitiveDatatypeDefinition.java:35)
at ca.uhn.fhir.context.ModelScanner.scanCompositeElementForChildren(ModelScanner.java:630)
at ca.uhn.fhir.context.ModelScanner.scanCompositeElementForChildren(ModelScanner.java:399)
at ca.uhn.fhir.context.ModelScanner.scanCompositeDatatype(ModelScanner.java:374)
at ca.uhn.fhir.context.ModelScanner.scan(ModelScanner.java:321)
at ca.uhn.fhir.context.ModelScanner.init(ModelScanner.java:202)
at ca.uhn.fhir.context.ModelScanner.(ModelScanner.java:113)
at ca.uhn.fhir.context.FhirContext.scanResourceTypes(FhirContext.java:431)
at ca.uhn.fhir.context.FhirContext.(FhirContext.java:140)
at ca.uhn.fhir.context.FhirContext.(FhirContext.java:113)
at ca.uhn.fhir.context.FhirContext.forDstu2(FhirContext.java:507)

The app is shpped with commons-lang3-3.4.jar dependency but seems to me that the Xiaomi custom image of Android already comes with a different version of the same library.
Do you know if there's some workaround to force using the latest version of commons-lang3 (shipped with my app) instead of the one shipped with the OS?

Thanks in advance.

Ciao,
Paolo

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Jun 27, 2016

I'm going to commit a fix which replaces the method call with something local. If anyone can figure out which version of the library is being used by the phone though that would be useful so that we can add a specific test.

@pperliti

This comment has been minimized.

pperliti commented Jun 27, 2016

Method inclusiveBetween in class Validate is present since version 3.0
https://commons.apache.org/proper/commons-lang/javadocs/api-3.0/org/apache/commons/lang3/Validate.html#inclusiveBetween(T,%20T,%20java.lang.Comparable)

Smartphones with this issue are both Xiaomi or Lenovo (from Android 4.4. to Android 6.0).

Logs do not reveal anything else...

1

2

3

We'll try your fix ASAP.

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Jun 27, 2016

FWIW the specific inclusiveBetween method we were calling was the one that takes long as its paramrter type, and that one was added in commons-lang3 3.3.... So I guess the Xiaomi phone might have a version of CL3 as new as 3.2

wmfgerrit pushed a commit to wikimedia/apps-android-wikipedia that referenced this issue Feb 9, 2017

Fix: copy ArrayUtils.removeAllOccurrences()
Some OEMs appear to have added a pre-v3.5, possibl pre-v3.4, version of
ArrayUtils to the system path which does not contain
removeAllOccurences(). Add a local copy

jamesagnew/hapi-fhir#394
https://rink.hockeyapp.net/manage/apps/226650/app_versions/79/crash_reasons/156658637
https://rink.hockeyapp.net/manage/apps/226650/app_versions/79/crash_reasons/156660777
https://rink.hockeyapp.net/manage/apps/226650/app_versions/79/crash_reasons/156663157

Change-Id: Ie361c193c115a5e551ca3ab175adce743259be89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment