flutter_file_picker icon indicating copy to clipboard operation
flutter_file_picker copied to clipboard

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

Open VladStarikovEk opened this issue 1 year ago • 57 comments

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 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" />

VladStarikovEk avatar Nov 08 '23 13:11 VladStarikovEk

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

github-actions[bot] avatar Nov 16 '23 01:11 github-actions[bot]

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]

DominicOrga avatar Nov 21 '23 00:11 DominicOrga

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

github-actions[bot] avatar Nov 29 '23 01:11 github-actions[bot]

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

TheCarpetMerchant avatar Dec 02 '23 12:12 TheCarpetMerchant

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

fesaworld avatar Dec 04 '23 07:12 fesaworld

@TheCarpetMerchant Sadly - no. We still experiencing it.

VladStarikovEk avatar Dec 05 '23 08:12 VladStarikovEk

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

TheCarpetMerchant avatar Dec 05 '23 08:12 TheCarpetMerchant

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

VladStarikovEk avatar Dec 05 '23 08:12 VladStarikovEk

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

github-actions[bot] avatar Dec 13 '23 01:12 github-actions[bot]

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

VladStarikovEk avatar Dec 13 '23 14:12 VladStarikovEk

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

github-actions[bot] avatar Dec 22 '23 01:12 github-actions[bot]

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

zambetpentru avatar Dec 30 '23 17:12 zambetpentru

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

github-actions[bot] avatar Jan 07 '24 01:01 github-actions[bot]

Up

TheCarpetMerchant avatar Jan 07 '24 11:01 TheCarpetMerchant

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

github-actions[bot] avatar Jan 15 '24 01:01 github-actions[bot]

Up

kiokumicu avatar Jan 15 '24 06:01 kiokumicu

up

arthurgiani avatar Jan 15 '24 13:01 arthurgiani

Up

maharramg avatar Jan 17 '24 15:01 maharramg

up

ambr89 avatar Jan 24 '24 16:01 ambr89

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

github-actions[bot] avatar Feb 01 '24 01:02 github-actions[bot]

up

mauriciotogneri avatar Feb 01 '24 08:02 mauriciotogneri

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

github-actions[bot] avatar Feb 10 '24 01:02 github-actions[bot]

up

zambetpentru avatar Feb 10 '24 09:02 zambetpentru

Pixel 7а, android 14 - same problem

devkeycloud avatar Feb 17 '24 13:02 devkeycloud

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

bypass112 avatar Feb 19 '24 13:02 bypass112

up

DarenF-20C avatar Feb 21 '24 08:02 DarenF-20C

up

erfan-git avatar Feb 21 '24 11:02 erfan-git

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

Cloud3886 avatar Feb 21 '24 18:02 Cloud3886

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

github-actions[bot] avatar Feb 29 '24 01:02 github-actions[bot]

Up

TheCarpetMerchant avatar Feb 29 '24 20:02 TheCarpetMerchant