Flutter_file_picker: PlatformException: File picker is already active

Created on 5 Nov 2020  Â·  7Comments  Â·  Source: miguelpruivo/flutter_file_picker

In the release version, the file selection dialog is not called, and an exception occurs when calling it again. The debug version is fine. Flutter is upgraded and cleared.

PlatformException(already_active, File picker is already active, null, null)
new issue

Most helpful comment

Fixed the dependency versions and everything worked!
android/gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

android/build.gradle:

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }

All 7 comments

@doomkin please post more details, such as Flutter version, simulator used, file picker version etc.

Flutter 1.22.3 • channel stable
Dart 2.10.3
targetSdkVersion 29
file_picker 2.0.12
Running on Xiaomi Mi 9T, users found an error on their other devices. The error occurred after upgrading Flutter and dependencies.

@doomkin looks like a dumb question, but have you tried cleaning and building again from scratch?

A good suggestion to clean and rebuild everything again, I have no other ideas :) If the error appeared under debugging, it would be clear in which direction to investigate the problem.

rm -R --force .pub-cache
flutter clean
flutter pub get
flutter pub upgrade
flutter pub run build_runner build --delete-conflicting-outputs
flutter build apk --target-platform android-arm64 --debug

app-debug.apk works fine (and app-profile.apk too)
Screenshot_2020-11-05-16-47-00-927_com google android documentsui

flutter build apk --target-platform android-arm64

app-release.apk falls
Screenshot_2020-11-05-16-52-19-384_ru parusinf timesheets

I used permission_handler 5.0.1+1, placed a rights request before calling file picker

  if (!(await Permission.storage.request().isGranted)) {
    throw l10n.permissionDenied;
  }
  FilePickerResult result = await FilePicker.platform.pickFiles(
    type: FileType.custom,
    allowedExtensions: ['csv'],
  );

now I get an exception MissingPluginException(No implementation found for method requestPermission on channel flutter.baseflow.com/permissions/methods)
Before that, I made a request for rights before opening the file. It looks like the rights request is broken.

  if (!(await Permission.storage.request().isGranted)) {
    throw l10n.permissionDenied;
  }
  final file = File(result.files.single.path);

I re-created the Flutter project, copied files from the old project there, and now it's not going to build

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /home/pa/data/devel/timesheets/build/file_picker/intermediates/library_manifest/debug/AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin file_picker...
Running Gradle task 'assembleAarRelease'...

/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:10: error: cannot find symbol
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  symbol:   class DefaultLifecycleObserver
  location: package androidx.lifecycle
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:20: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:38: error: cannot find symbol
            implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                               ^
  symbol:   class DefaultLifecycleObserver
  location: class FilePickerPlugin
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:45: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:49: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:53: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:57: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:61: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:66: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:277: error: cannot find symbol
            this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                             ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FilePickerPlugin
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:278: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.addObserver(this.observer);
                                           ^
/home/pa/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.12/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:287: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.removeObserver(this.observer);
                                              ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

Exception: The plugin file_picker could not be built due to the issue above.

Fixed the dependency versions and everything worked!
android/gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

android/build.gradle:

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

creativecreatorormaybenot picture creativecreatorormaybenot  Â·  6Comments

JAICHANGPARK picture JAICHANGPARK  Â·  3Comments

edandaria picture edandaria  Â·  5Comments

zs-dima picture zs-dima  Â·  4Comments

ElaineSchwner picture ElaineSchwner  Â·  4Comments