kotlin-toolkit icon indicating copy to clipboard operation
kotlin-toolkit copied to clipboard

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

Open Yahoo-Mike opened this issue 1 year ago • 3 comments

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")

Yahoo-Mike avatar May 09 '25 04:05 Yahoo-Mike

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 avatar May 14 '25 15:05 mickael-menu

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

mickael-menu avatar May 15 '25 11:05 mickael-menu

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

Yahoo-Mike avatar May 15 '25 22:05 Yahoo-Mike