Skip to content
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

NoClassDefFoundError on API 23 and lower #148

Open
PierreNomade opened this issue Sep 11, 2019 · 6 comments
Open

NoClassDefFoundError on API 23 and lower #148

PierreNomade opened this issue Sep 11, 2019 · 6 comments
Labels

Comments

@PierreNomade
Copy link

Hi all,

We are using ucum library on an Android project.
But it appears that we can't start our app on API 23 and lower.

When we try it, we got this error :

    java.lang.NoClassDefFoundError: tec.uom.se.function.RationalConverter
         at tec.uom.se.AbstractUnit.divide(AbstractUnit.java:426)
         at tec.uom.se.AbstractUnit.divide(AbstractUnit.java:69)
         at tec.uom.se.unit.Units.<clinit>(Units.java:172)

Here is our gradle dependencies :

implementation 'systems.uom:systems-quantity:1.0'
implementation 'systems.uom:systems-common-java8:1.0'
implementation 'systems.uom:systems-unicode-java8:1.0'
implementation 'systems.uom:systems-ucum-java8:1.0'

Works perfectly on API 24 and higher.
Do you have any ideas of what could be the problem ?

Thank you !

@keilw
Copy link
Member

keilw commented Sep 11, 2019

On Android, that is an interesting question, do you try using it with Java or Kotlin? Possible that API 23 is not Java 8 compatible yet, then it would explain why.
While not completely clear either there is some evidence, Java 8 features may only work properly above Android API 24: https://stackoverflow.com/questions/35934528/does-java-8-work-on-android-api-24-and-above-or-you-can-use-in-lower-api

@keilw keilw added the analysis label Sep 11, 2019
@PierreNomade
Copy link
Author

Thank you for the answer.

We are using Java.

Yes it seems that the problem is Java 8.
But is there a workaround to use ucum on API 23 and lower ?

@keilw
Copy link
Member

keilw commented Sep 11, 2019

I'm afraid UCUM was not done with the RI of JSR 363. I am not sure what the exact reason was, but I believe some of the classes made use of Java SE 8 right from the start. I can't say if that was ever used on Android, but Eclipse UOMo including version 0.7 offers a UCUM module with "late binding" so it uses the full ucum-essence.xml file with the whole UCUM spec but some operations have less compile-time type-safety. Would that help your use case? We have not fully mavenized UOMo 0.7 or above, not sure, if that's a problem e.g. if you build with Gradle?

@keilw
Copy link
Member

keilw commented Sep 12, 2019

Oh and if Kotlin was an option for you and your Android app, it seems Physikal had UCUM support ever since in its complete-units module. As Kotlin bytecode seemed compatible even all the way back to Java 6 or 7, it is said to work on very old Android API levels. HTH?

@PierreNomade
Copy link
Author

Yes we are building our project with Gradle.

I think Kotlin could be an option, if it can allows us to have UCUM on lower API.
We are going to check this solution, thank you for the help !

@keilw
Copy link
Member

keilw commented Sep 12, 2019

Please let us know, if that works, you could ask @ejberry or @zjuhasz where they use Physikal on Android. I heard they do, but I don't know which devices or versions. A main reason UCUM was never used under the first RI is, that it relies on ResourceBundle for its formatting and parsing, something the 1.0 RI avoided because it's not available on Java ME Embedded. That's why backporting it could be cumbersome, so if Kotlin solves your problem, it would be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants