Skip to content

Duplicate class com.shockwave.pdfium.BuildConfig when using readium-adapter-pdfium #662

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

Closed
Yahoo-Mike opened this issue May 9, 2025 · 3 comments · Fixed by #663
Closed

Comments

@Yahoo-Mike
Copy link

Describe the bug

When I add org.readium.kotlin-toolkit:readium-adapter-pdfium:3.1.0 to my build dependencies, the build fails with several errors like this:

Duplicate class com.shockwave.pdfium.BuildConfig found in modules readium-adapter-pdfium-document-3.1.0.aar -> readium-adapter-pdfium-document-3.1.0-runtime (org.readium.kotlin-toolkit:readium-adapter-pdfium-document:3.1.0) and readium-adapter-pdfium-navigator-3.1.0.aar -> readium-adapter-pdfium-navigator-3.1.0-runtime (org.readium.kotlin-toolkit:readium-adapter-pdfium-navigator:3.1.0)

Duplicate class com.shockwave.pdfium.PdfDocument found in modules readium-adapter-pdfium-document-3.1.0.aar -> readium-adapter-pdfium-document-3.1.0-runtime (org.readium.kotlin-toolkit:readium-adapter-pdfium-document:3.1.0) and readium-adapter-pdfium-navigator-3.1.0.aar -> readium-adapter-pdfium-navigator-3.1.0-runtime (org.readium.kotlin-toolkit:readium-adapter-pdfium-navigator:3.1.0)

etc

How to reproduce?

  1. using AndroidStudio Meerkat (patch 2) with AGP 8.9.2, create a new "EmptyViewsActivity" project with minSdk=26
  2. in the build.gradle.kts (:app) add this:

dependencies {
implementation("org.readium.kotlin-toolkit:readium-adapter-pdfium:3.1.0")
}

  1. by the way you also need to desugar, even if minSdk=26. Readme.md says you shouldn't have to, but the build insists anyway

android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}

dependencies {
coreLibraryDesugaring( "com.android.tools:desugar_jdk_libs:2.1.5" )
}

  1. sync and assemble

Readium version

3.1.0

Android API version

min=26, target=35

Additional context

On the "main" git branch, I can see com.shockwave.pdfium being pulled in by only one file: readium/adapters/pdfium/document/.../PdfiumDocument.kt

Excluding readium-adapter-pdfium-document from the build results in a successful compile, but obviously removes functionality from the library:

implementation("org.readium.kotlin-toolkit:readium-adapter-pdfium:3.1.0") {
    exclude(group="org.readium.kotlin-toolkit",module="readium-adapter-pdfium-document")
}

Trying to sneak the pdfium-document library back in separately leads to the same duplication class errors:

implementation("org.readium.kotlin-toolkit:readium-adapter-pdfium:3.1.0") {
    exclude(group="org.readium.kotlin-toolkit",module="readium-adapter-pdfium-document")
}
implementation("org.readium.kotlin-toolkit:readium-adapter-pdfium-document:3.1.0")
@mickael-menu
Copy link
Member

Thank you for reporting this issue. I think it was only happening when using the builds from Maven Central. It should be fixed in #663 hopefully, I'll do a patch release once it's reviewed and merged.

@mickael-menu mickael-menu linked a pull request May 14, 2025 that will close this issue
@mickael-menu
Copy link
Member

3.1.1 is being deployed to Maven Central, let me know if it fixed the issue for you. Thanks!

@Yahoo-Mike
Copy link
Author

Worked like a charm. Thanks for fixing it so quickly!

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

Successfully merging a pull request may close this issue.

2 participants