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.32k stars 655 forks source link

File picker is already active #736

Closed Shakhboz95 closed 3 years ago

Shakhboz95 commented 3 years ago

Sometimes picking files will not work. I don't know when. 1-2 times it works, after that stops working and shows this error:

I/flutter (25833): [MethodChannelFilePicker] Platform exception: PlatformException(already_active, File picker is already active, null, null) E/flutter (25833): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(already_active, File picker is already active, null, null)

is there any solution for this?

miguelpruivo commented 3 years ago

Hi, I need more details on how to replicate this.

Shakhboz95 commented 3 years ago
     chooseZipFile({bool` isUpdate = false, int index}) async {
        var result = await FilePicker.platform.pickFiles(
        type: FileType.custom, allowedExtensions: ["doc", "xls", "pdf", "zip"]);

    if (result != null) {
      File file = File(result.files.single.path);
      int sizeInBytes = file.lengthSync();
      double sizeInMb = sizeInBytes / (1024 * 1024);
      print("file name:  " + result.files.first.name);
      if (sizeInMb > 5) {
        ToastUtils.toastErrorGeneral("file size is exceeded", _context);
      } else {
        if (isUpdate) {
          _zipTitle[index] = (result.files.first.name);
          _zipChosen[index] = true;
        } else {
          _zipTitle.add(result.files.first.name);
          _zipChosen.add(true);
        }
        notifyListeners();
      }
      // file.
    } else {
      // User canceled the picker

    }
  }

Here is the code. The logic is Users can pick another file if they need after one file.

dala00 commented 3 years ago

I got same message on Android & file_picker: 2.1.7. But may be not same way of this issue. I called pickFiles and disallow permission and pickFiles again.

miguelpruivo commented 3 years ago

Does the issue applies to iOS or Android?

Shakhboz95 commented 3 years ago

Unfortunately, I dont have any info about this issue on IOS, I tested it only on android platform, 3 devices displayed this error

indrajit-roy commented 3 years ago

Facing the same issue in file_picker: 2.1.7. Using the demo app, it seems like, just on the release version, the Future,

(await FilePicker.platform.pickFiles( type: _pickingType, allowMultiple: _multiPick, allowedExtensions: (_extension?.isNotEmpty ?? false) ? _extension?.replaceAll(' ', '').split(',') : null, ))

does not complete and the Circular Progress Indicator keeps spinning.

This does not happen in debug. Only on release and build apk.

My device is the Samsung S10 lite, API 30. flutter version 2.0.5.

miguelpruivo commented 3 years ago

Ok, thank you for the input. I’ll have to replicate it on release, might be related.

Pato05 commented 3 years ago

I am experiencing the same problem also on debug builds, it seems like the FilePicker.platform.pickFiles() future never completes..

Edit: I noticed I was overriding onActivityResult(...) but I wasn't calling super.onActivityResult(...), that was my fix; hope it helps anyone even if I highly doubt it, given this issue seems to be different from my original problem.

sumanwebidigital commented 3 years ago

It is still not working, when I install app for first time.

miguelpruivo commented 3 years ago

@Pato05 this is one of those issues that some have it some don't and without easy way to replicate it, hence, this make me believe that could be user-implementation related — like it happened to you.

miguelpruivo commented 3 years ago

Closing since this likely is related to the app's implementation that is requesting multiple pickers before closing the previous one.

mohsinnaqvi606 commented 2 years ago

I am getting same issue on Android Platform after adding some native code for android side.

While compiling project from android side I got this error "The option setting 'android.enableR8=true' is deprecated. It will be removed in version 5.0 of the Android Gradle plugin. You will no longer be able to disable R8 Affected Modules: file_picker"

Solutions that I have already tried 1) downgraded gradle to '3.5.1' 2) upgraded gradle to '7.0.2' (latest) 3) flutter clean & flutter pug get 4) added supper.onActivityResult in onActivityResult function of MainActivity

But none did work.

Currently I am using gradle '4.1.0' with dist 'gradle-6.7-all.zip' and kotlin version = '1.6.0-M1'

Here is flutter doctor result [√] Flutter (Channel stable, 2.5.1, on Microsoft Windows [Version 10.0.19043.1237], locale en-PK) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Chrome - develop for the web [√] Android Studio (version 2020.3) [!] Android Studio (version 4.1) X Unable to determine bundled Java version. [√] VS Code (version 1.59.1) [√] Connected device (3 available)

! Doctor found issues in 1 category.

fryyd commented 2 years ago

You can replicate this on iOS by having allowCompression: true, then pick a large file (the file i picked was hevc encoded). While this process is running, call the FilePicker.platform.pickFiles method again, and this time the error will be thrown: I/flutter (25833): [MethodChannelFilePicker] Platform exception: PlatformException(already_active, File picker is already active, null, null)

lore-co commented 2 years ago

Problem is still there and happens lot of times

aucshow-wjb commented 1 year ago

The issue already happened many times to me.... not ended yet.