flutter_file_picker
flutter_file_picker copied to clipboard
Unable to pick files with `custom` or `any` file type on Android 14
Describe the bug
When picking files with custom
or any
file type on Android 14, when one or multiple files are picked it just closes assuming that the user closed it. I also got I/FilePickerDelegate(21624): User cancelled the picker request
message in logs.
When picking image
, audio
, video
or media
everything works fine, but the picker has a gallery
UI, rather then file explorer
UI. I also checked this on Android 13 emulator - it works file there.
Platform
- [X] Android
- [ ] iOS
- [ ] Web
- [ ] Desktop
Platform OS version Pixel 5 - Android 14
How are you picking?
final pickerResult = await _filePicker.pickFiles(
type: FileType.custom,
allowMultiple: true,
allowedExtensions: ['jpg', 'jpeg', 'png', 'pdf'],
);
or
final pickerResult = await _filePicker.pickFiles(
type: FileType.any,
);
Details to reproduce the issue
Error Log
D/FilePickerDelegate(21624): Selected type */*
I/FilePickerDelegate(21624): User cancelled the picker request
Screenshots and/or video
https://github.com/miguelpruivo/flutter_file_picker/assets/99865323/ade3be44-b8f9-48b8-a509-d7aff62de0ad
Flutter Version details
❯ flutter doctor -v
[✓] Flutter (Channel stable, 3.13.9, on macOS 14.1 23B74 darwin-arm64, locale en-UA)
• Flutter version 3.13.9 on channel stable at /Users/vstarikov/fvm/versions/3.13.9
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d211f42860 (2 weeks ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/vstarikov/Library/Android/sdk
• Platform android-34, build-tools 33.0.0
• ANDROID_HOME = /Users/vstarikov/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.13.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Community Edition (version 2022.1.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] Connected device (3 available)
• Pixel 5 (mobile) • 0B241FDD4001ZT • android-arm64 • Android 14 (API 34)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.1 23B74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.123
[✓] Network resources
• All expected network resources are available.
• No issues found!
Additional context
Requested permissions in AndroidManifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
This issue is stale because it has been open for 14 days with no activity.
I am also experiencing this issue, but in my case it occurs on my Pixel 4A Android 13. What's weird is that the file picker does not work on my main (large) project, but works fine on a newly created test project.
How are you picking?
FilePicker.platform.pickFiles(
allowMultiple: true,
allowedExtensions: ['pdf'],
type: FileType.custom,
);
Output (Main Project):
D/FilePickerUtils(26411): Allowed file extensions mimes: [application/pdf]
D/FilePickerDelegate(26411): Selected type */*
I/FilePickerDelegate(26411): User cancelled the picker request
Output (Test Project):
D/FilePickerUtils(28311): Allowed file extensions mimes: [application/pdf]
D/FilePickerDelegate(28311): Selected type */*
I/FilePickerUtils(28311): Caching from URI: content://com.android.providers.media.documents/document/document%3A83
D/FilePickerUtils(28311): File loaded and cached at:/data/user/0/com.example.file_picker_test/cache/file_picker/dummy.pdf
D/FilePickerDelegate(28311): File path:[com.mr.flutter.plugin.filepicker.FileInfo@144d1d0]
This issue is stale because it has been open for 14 days with no activity.
@VladStarikovEk Did you manage to solve this ? If so, how ?
i got the same problem, and i found a way to solve it..
you can try changing android:launchMode="singleInstance" in /main/AndroidManifest.xml to android:launchMode="singleTop"
@TheCarpetMerchant Sadly - no. We still experiencing it.
@VladStarikovEk there's a pull request opened for the fix. Just got it into prod and users confirm it works. The pull request is 35 commits behind, so I made my own fork for it.
@VladStarikovEk there's a pull request opened for the fix. Just got it into prod and users confirm it works. The pull request is 35 commits behind, so I made my own fork for it.
Will try it. Thanks!
This issue is stale because it has been open for 14 days with no activity.
I'm glad to report that the fix from this PR works.
For now I'm using this way to add file_picker
dependency:
file_picker:
git:
url: https://github.com/melWiss/flutter_file_picker.git
This issue is stale because it has been open for 14 days with no activity.
I'm glad to report that the fix from this PR works. For now I'm using this way to add
file_picker
dependency:file_picker: git: url: https://github.com/melWiss/flutter_file_picker.git
I confirm it's also working on my Samsung Galaxy when upgraded to Android 14
This issue is stale because it has been open for 14 days with no activity.
Up
This issue is stale because it has been open for 14 days with no activity.
Up
up
Up
up
This issue is stale because it has been open for 14 days with no activity.
up
This issue is stale because it has been open for 14 days with no activity.
up
Pixel 7а, android 14 - same problem
Galaxy S22 Ultra, Android 14 - same problem. Can also add the FileType.audio is affected.
up
up
var localFile = await FilePicker.platform.pickFiles( type: FileType.custom, allowMultiple: false, allowedExtensions: ['pdf'], withData: true, );
poco f3 gt Android 13 - same problem
previously used to work but after changing to android:launchMode="singleInstance"
it gave this issue.
This fork works and solves this issue.
file_picker: git: url: https://github.com/melWiss/flutter_file_picker.git
This issue is stale because it has been open for 14 days with no activity.
Up