Repository navigation
fix(android): remove Apache Tika dependency for MIME type detection - #2104
Merged
navaronbracke merged 2 commits intoJul 31, 2026
Merged
Conversation
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
requested changes
Jul 31, 2026
| private const val CSV_MIME_TYPE = "text/csv" | ||
| // Fallback MIME type used when neither the file name extension nor | ||
| // content sniffing can determine a type, matching the value used by | ||
| // most content-detection libraries (and previously Apache Tika) for |
Collaborator
There was a problem hiding this comment.
Since Tika will be removed, I would remove the reference to it in docs. I don't think that years into the future, when someone reads this code, they will have the original context.
Suggested change
| // most content-detection libraries (and previously Apache Tika) for | |
| // most content-detection libraries for |
|
|
||
| // Sniffs [bytes] for a MIME type using URLConnection's built-in magic-number | ||
| // detection. This is a best-effort fallback for when the file name has no | ||
| // usable extension, without pulling in a full content-detection dependency. |
Collaborator
There was a problem hiding this comment.
Same reason as above
Suggested change
| // usable extension, without pulling in a full content-detection dependency. | |
| // usable extension. |
Trims the "(and previously Apache Tika)" and "without pulling in a full content-detection dependency" asides per review feedback - they only make sense with context that won't exist once Tika is fully removed from the codebase.
navaronbracke
approved these changes
Jul 31, 2026
navaronbracke
pushed a commit
that referenced
this pull request
Jul 31, 2026
#2104 merged before this correction landed on that branch. This fix targets the v11.x hotfix release, so the CHANGELOG entry belongs under its own 11.0.3 heading (positioned above 11.0.2 to match release chronology), not the unreleased 12.0.0-beta.8 bucket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
android/implementation, used only to detect a MIME type forsaveFile().MimeTypeMap(with the existing CSV special-case preserved), falling back toURLConnection.guessContentTypeFromStreamcontent sniffing only when the file name has no usable extension.tika-coredependency frombuild.gradle.kts.Companion PRs:
11.0.xline (based onv11.0.2).file_picker_androidspecifically.Fixes #2101
Test plan
flutter build apk --debuginexample/compiles cleanly against this change.CONTRIBUTING.md, native platform code is not currently unit tested), so verification was via compilation and manual review of the MIME-mapping logic against the previous Tika-based behavior.