Description
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?
- using AndroidStudio Meerkat (patch 2) with AGP 8.9.2, create a new "EmptyViewsActivity" project with minSdk=26
- in the build.gradle.kts (:app) add this:
dependencies {
implementation("org.readium.kotlin-toolkit:readium-adapter-pdfium:3.1.0")
}
- 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" )
}
- 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")