miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.31k stars 653 forks source link

Unable to pick files with `custom` or `any` file type on Android 14 #1404

Closed VladStarikovEk closed 1 week ago

VladStarikovEk commented 10 months ago

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

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

Screenshot 2023-11-08 at 15 35 34

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" />
github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 14 days with no activity.

DominicOrga commented 9 months ago

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]
github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 14 days with no activity.

TheCarpetMerchant commented 9 months ago

@VladStarikovEk Did you manage to solve this ? If so, how ?

fesaworld commented 9 months ago

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"

image

VladStarikovEk commented 9 months ago

@TheCarpetMerchant Sadly - no. We still experiencing it.

TheCarpetMerchant commented 9 months ago

@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 commented 9 months ago

@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!

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 14 days with no activity.

VladStarikovEk commented 8 months ago

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
github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 14 days with no activity.

zambetpentru commented 8 months ago

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

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 14 days with no activity.

TheCarpetMerchant commented 8 months ago

Up

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 14 days with no activity.

kiokumicu commented 7 months ago

Up

arthurgiani commented 7 months ago

up

maharramg commented 7 months ago

Up

ambr89 commented 7 months ago

up

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 14 days with no activity.

mauriciotogneri commented 7 months ago

up

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 14 days with no activity.

zambetpentru commented 6 months ago

up

devkeycloud commented 6 months ago

Pixel 7а, android 14 - same problem

bypass112 commented 6 months ago

Galaxy S22 Ultra, Android 14 - same problem. Can also add the FileType.audio is affected.

DarenF-20C commented 6 months ago

up

erfan-git commented 6 months ago

up

Cloud3886 commented 6 months ago

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

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 14 days with no activity.

TheCarpetMerchant commented 6 months ago

Up

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 7 days with no activity.

zambetpentru commented 6 months ago

Bounce

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 7 days with no activity.

zambetpentru commented 5 months ago

Bounce, bad bot

miguelpruivo commented 5 months ago

What is the solution purposed for this? Not sure what about the consequences of limiting it for single. I recall that it could introduce some issues but don't remember which.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 7 days with no activity.

zambetpentru commented 5 months ago

Bad bot

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 7 days with no activity.

TheManuz commented 5 months ago

Bad bot

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity.

zambetpentru commented 4 months ago

Bad bot

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity.

zambetpentru commented 4 months ago

Bad bot

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity.

zambetpentru commented 4 months ago

Bad bot

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 7 days with no activity.

TheManuz commented 4 months ago

Yeah, we know it. Bad bot

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 7 days with no activity.

TheManuz commented 3 months ago

This is becoming ridicolous. Bad bot!

stan-at-work commented 3 months ago

up