Skip to content

fix(file_picker_android): remove Apache Tika dependency for MIME type detection - #2105

Merged
navaronbracke merged 2 commits into
vicajilau:masterfrom
ryanaidilp:fix/2101-remove-tika-file-picker-android
Jul 31, 2026
Merged

navaronbracke merged 2 commits into
vicajilau:masterfrom
ryanaidilp:fix/2101-remove-tika-file-picker-android

Conversation

@ryanaidilp

Copy link
Copy Markdown
Contributor

Summary

  • Removes the Apache Tika dependency (~300 KB) from the federated file_picker_android package, used only to detect a MIME type for saveFile().
  • MIME types are now resolved from the file name extension via MimeTypeMap (with the existing CSV special-case preserved), falling back to URLConnection.guessContentTypeFromStream content sniffing only when the file name has no usable extension.
  • Removes the now-unused Tika proguard rules and the tika-core dependency from build.gradle.kts.
  • Bumps file_picker_android to 1.0.1 with a CHANGELOG entry.

This is the file_picker_android-specific PR requested in #2101, as a companion to:

  • The equivalent fix for the still-bundled legacy android/ implementation on master.
  • A backport of the same fix targeting the 11.0.x line (based on v11.0.2).

Fixes #2101

Test plan

  • The Kotlin change mirrors the identical fix already verified to compile cleanly in the legacy android/ implementation (same imports, same dependency versions).
  • This package has no example app of its own in the repo, so the change wasn't independently exercised through a full Gradle build here — it's textually identical to the already-verified fix.

… detection

Tika added ~300 KB to the Android binary just to detect a MIME type in
saveFile(). MIME types are now resolved from the file name extension
via MimeTypeMap, with URLConnection.guessContentTypeFromStream as a
content-sniffing fallback when no usable extension is available.

Fixes vicajilau#2101

@navaronbracke navaronbracke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with nits

name: file_picker_android
description: Android implementation of the file_picker plugin.
version: 1.0.0
version: 1.0.1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted, file_picked_android is not yet published iirc (Although there is a different naming issue that we need to look at, apparently there's a naming conflict with the plugin name)

@@ -1,3 +1,7 @@
## 1.0.1

- Removed the Apache Tika dependency (~300 KB) used for MIME type detection in `saveFile()`. MIME types are now resolved from the file name extension via `MimeTypeMap`, with `URLConnection.guessContentTypeFromStream` as a content-sniffing fallback when no extension is available. [#2101](https://github.com/miguelpruivo/flutter_file_picker/issues/2101)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved under 1.0.0

- Revert the version bump: file_picker_android hasn't been published
  yet, so there's no prior release to patch against.
- Fold the CHANGELOG entry into the existing 1.0.0 heading instead of
  a new 1.0.1 section.
- Drop stale Tika references from doc comments, same as the
  companion android/ fix.
@navaronbracke
navaronbracke merged commit 224a0f5 into vicajilau:master Jul 31, 2026
11 checks passed
@navaronbracke

Copy link
Copy Markdown
Collaborator

@ryanaidilp Feel free to open a pull request that we can hotfix to v11.x now :)

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.

Suggestion: Remove Apache Tika dependency on Android to reduce app size

2 participants