简体   繁体   中英

JScience unit of measurement library incompatible with android

I have a use-case in my android application where I need to save a quantity, perform calculations on it, and display it in a unit of the user's choice (from a predefined list).

JScience fit this need perfectly, but I cannot compile the application for Android due to the following error:

Error: Program type already present: javolution.ContextTestSuite$1

I note that JSCience is powered by javolution. This leaves me with two options: find a different library (I've found the JSR-363 API but I have been unable to find documentation on it beyond a few use cases as discussed in the links in this SO response ; for example, those links do not discuss the concrete unit types and where they can be found) or fix the incompatibility I have experienced between JScience and Android.

I will accept a solution that does either of those.

Not sure what else uses it, but this is caused by a double dependency of javolution. What you can do is in the build.gradle (Module app) file, you can exclude javolution when you include jscience.

dependencies {
    implementation 'com.android.support:support-v4:28.0.0'
    ...
    implementation('org.jscience:jscience:4.3.1') {
        exclude group: "org.javolution"
    }
}

Clean/Rebuild Project and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM