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

Fix crash with ChannelZipContainer before API 26 #403

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

mickael-menu
Copy link
Member

LinkOption is only available since API 26, so ChannelZipContainer crashed with:

java.lang.NoClassDefFoundError: Failed resolution of: [Ljava/nio/file/LinkOption;
	at org.readium.r2.shared.util.archive.channel.compress.utils.IOUtils.<clinit>(IOUtils.java:46)
	at org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile.tryToLocateSignature(ZipFile.java:1392)
	at org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile.positionAtEndOfCentralDirectoryRecord(ZipFile.java:1071)
	at org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile.positionAtCentralDirectory(ZipFile.java:941)
	at org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile.populateFromCentralDirectory(ZipFile.java:912)
	at org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile.<init>(ZipFile.java:526)
	at org.readium.r2.shared.util.archive.channel.compress.archivers.zip.ZipFile.<init>(ZipFile.java:459)
	at org.readium.r2.shared.util.archive.channel.ChannelZipArchiveFactory.create(ChannelZipContainer.kt:191)
	at org.readium.r2.shared.resource.CompositeArchiveFactory.create(Factories.kt:172)
	at org.readium.r2.shared.asset.AssetRetriever.retrieve(AssetRetriever.kt:259)
	at org.readium.r2.testapp.domain.Bookshelf.addBook(Bookshelf.kt:126)
	at org.readium.r2.testapp.domain.Bookshelf.addBookFeedback(Bookshelf.kt:116)
	at org.readium.r2.testapp.domain.Bookshelf.addBookFeedback$default(Bookshelf.kt:112)
	at org.readium.r2.testapp.domain.Bookshelf$addPublicationFromStorage$1.invokeSuspend(Bookshelf.kt:108)

Luckily, LinkOption was not really used, so I just removed the references.

To reproduce, use "Read from shared storage" on an API 25 emulator.

@mickael-menu mickael-menu requested a review from qnga October 2, 2023 11:49
@mickael-menu mickael-menu merged commit 4850dd3 into v3 Oct 2, 2023
3 checks passed
@mickael-menu mickael-menu deleted the fix/crash-api-26 branch October 2, 2023 12:17
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 this pull request may close these issues.

2 participants