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

Duplicate classes and files when depending on a project using ormlite-core #141

Open
aberaud opened this issue Sep 8, 2022 · 7 comments

Comments

@aberaud
Copy link

aberaud commented Sep 8, 2022

Our Android project uses ormlite-android and depends on another project that uses ormlite-core.

The base dependency includes ormlite with:
implementation ("com.j256.ormlite:ormlite-core:6.1")

And the Android project includes ormlite with:
implementation ("com.j256.ormlite:ormlite-android:6.1")

When building the Android project, we get the following errors:

> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.j256.ormlite.dao.BaseDaoImpl found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseDaoImpl$1 found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseDaoImpl$2 found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseDaoImpl$3 found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseDaoImpl$4 found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseDaoImpl$5 found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseDaoImpl$6 found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.BaseForeignCollection found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.CloseableIterable found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.CloseableIterator found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.CloseableSpliterator found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.CloseableSpliteratorImpl found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.CloseableWrappedIterable found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
     Duplicate class com.j256.ormlite.dao.CloseableWrappedIterableImpl found in modules ormlite-android-6.1 (com.j256.ormlite:ormlite-android:6.1) and ormlite-core-6.1 (com.j256.ormlite:ormlite-core:6.1)
(...)
com.android.builder.merge.DuplicateRelativeFileException: 2 files found with path 'com/j256/ormlite/core/LICENSE.txt'.

This was working fine with Ormlite 5.x

@j256
Copy link
Owner

j256 commented Sep 8, 2022

See the ChangeLog: https://raw.githubusercontent.com/j256/ormlite-core/master/src/main/javadoc/doc-files/changelog.txt

In 6.0 we migrated all of the core classes into the JDBC and Android versions:

* JDBC: ormlite-jdbc jar now includes the -core classes.  No need to import ormlite-core jar anymore.
* ANDROID: ormlite-android jar now includes the -core classes.  No need to import ormlite-core jar anymore.

@j256 j256 closed this as completed Sep 8, 2022
@aberaud
Copy link
Author

aberaud commented Sep 9, 2022

Thanks for the reply, however the dependency is not an Android dependency but a pure Java/kotlin dependency, so it can't/shouldn't use the Android package.

What to do in that case ? Thanks.

@aberaud
Copy link
Author

aberaud commented Sep 12, 2022

@j256 Any idea? This issue prevents us from migrating to ORMLite 6.x

Why not declaring a dependency from ormlite-android to ormlite-core, instead of including all ormlite-core classes in ormlite-android, which seems odd?

@j256
Copy link
Owner

j256 commented Oct 4, 2022

Frankly I didn't foresee this issue. I never thought that someone would ever want to depend on both of them. Not everyone uses maven or gradle or some other dependency management system that would automatically pull in jars so it was an attempt to make it easier for folks.

Maybe I should consider rolling that back even though it is going to be painful.

@HosseinKurd
Copy link

How to solve it?

@jamalnay
Copy link

You just have to exclude the duplicated libraries in gradle like so:

implementation('org.osmdroid:osmdroid-geopackage:6.1.x') {
        exclude group: 'org.osmdroid.gpkg'
        exclude module: 'ormlite-core'
        exclude group: 'com.j256.ormlite'
    }

@vladaman
Copy link

vladaman commented Oct 14, 2024

@j256 I've got same issue when importing jdbc into our Android project (we use JDBC internally as well)

    implementation 'com.j256.ormlite:ormlite-android:6.1'
    implementation 'com.j256.ormlite:ormlite-jdbc:6.1'

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

No branches or pull requests

5 participants