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 653 forks source link

The plugin file_picker could not be built due to the issue above with Flutter 1.12.13+hotfix.9 #223

Closed Blasanka closed 4 years ago

Blasanka commented 4 years ago

My project is migrated to AndroidX and worked earlier with Flutter version 1.12.13+hotfix.7 and FilePicker version 1.4.3+2

Flutter Doctor output:

[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.657], locale en-US)
    • Flutter version 1.12.13+hotfix.9 at C:\flutter
    • Framework revision f139b11009 (4 days ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\BLiyanage\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = C:\Users\BLiyanage\AppData\Local\Android\sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 43.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] IntelliJ IDEA Community Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3
    • Flutter plugin version 44.0.3
    • Dart plugin version 193.6494.35

[√] VS Code, 32-bit edition
    • VS Code at C:\Program Files (x86)\Microsoft VS Code
    • Flutter extension version 3.4.1

[√] VS Code, 64-bit edition (version 1.42.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.4.1

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

Error log:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
17 actionable tasks: 2 executed, 15 up-to-date

C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:12: error: cannot find
 symbol
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  symbol:   class DefaultLifecycleObserver
  location: package androidx.lifecycle
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:19: error: cannot find
 symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:35: error: cannot find
 symbol
            implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                               ^
  symbol:   class DefaultLifecycleObserver
  location: class FilePickerPlugin
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:42: error: method does
 not override or implement a method from a supertype
        @Override
        ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:46: error: method does
 not override or implement a method from a supertype
        @Override
        ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:50: error: method does
 not override or implement a method from a supertype
        @Override
        ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:54: error: method does
 not override or implement a method from a supertype
        @Override
        ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:58: error: method does
 not override or implement a method from a supertype
        @Override
        ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:63: error: method does
 not override or implement a method from a supertype
        @Override
        ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:253: error: cannot fin
d symbol
            this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                             ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FilePickerPlugin
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:254: error: incompatib
le types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.addObserver(this.observer);
                                           ^
C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:262: error: incompatib
le types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
        this.lifecycle.removeObserver(this.observer);
                                          ^
Note: C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerDelegate.java uses or overri
des a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
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 1m 51s

The plugin file_picker could not be built due to the issue above.
miguelpruivo commented 4 years ago

@Blasanka this might sound dumb, but have you tried to flutter clean and then flutter build again after upgrading?

I highly doubt that a hotfix could introduce breaking changes at plugin's implementation, but...

Blasanka commented 4 years ago

Yes, even tried pub cache repair, cleaning building android directory with AS also did not work.

miguelpruivo commented 4 years ago

@Blasanka this looks like project related, otherwise I would say it would not work for everyone as it's complaining to dependencies not found. I'm still at hotfix.8, could you downgrade to hotfix.8 and let me know if it works for you?

Could it be that hotfix.9 introduced breaking changes?

Blasanka commented 4 years ago

Same issue with the eariler version ^1.4.3+2.

miguelpruivo commented 4 years ago

@Blasanka no, I'm suggesting 1.5.1 and Flutter stable version 1.12.13+hotfix.8

Blasanka commented 4 years ago

Im on it. Can I know your Dart SDK version? My project version is sdk: ">=2.6.0 <3.0.0"

miguelpruivo commented 4 years ago

This is where I'm currently at:

✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.4 19E266,
    locale pt-PT)
    • Flutter version 1.12.13+hotfix.8 at /Users/miguelruivo/devtools/flutter
    • Framework revision 0b8abb4724 (7 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0
oumi commented 4 years ago

I had a similar a problem, i tried to downgrade the flutter version to 1.12.13+hotfix.8 . But i still have the same error. The result of building with file_picker: ^1.4.0:

Deprecated` Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings 17 actionable tasks: 1 executed, 16 up-to-date

C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:12: error: cannot find symbol import androidx.lifecycle.DefaultLifecycleObserver; ^ symbol: class DefaultLifecycleObserver location: package androidx.lifecycle C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:19: error: cannot find symbol import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter; ^ symbol: class FlutterLifecycleAdapter location: package io.flutter.embedding.engine.plugins.lifecycle C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:35: error: cannot find symbol implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { ^ symbol: class DefaultLifecycleObserver location: class FilePickerPlugin C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:42: error: method does not override or implement a method from a supertype @Override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:46: error: method does not override or implement a method from a supertype @Override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:50: error: method does not override or implement a method from a supertype @Override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:54: error: method does not override or implement a method from a supertype @Override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:58: error: method does not override or implement a method from a supertype @Override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:63: error: method does not override or implement a method from a supertype @Override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:253: error: cannot find symbol this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); ^ symbol: variable FlutterLifecycleAdapter location: class FilePickerPlugin C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:254: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.addObserver(this.observer); ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:262: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.removeObserver(this.observer); ^ Note: C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerDelegate.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 12 errors

FAILURE: Build failed with an exception.

BUILD FAILED in 3s

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

and my flutter doctor output:**

C:\flutter\bin\flutter.bat doctor --verbose [√] Flutter (Channel unknown, v1.12.13+hotfix.8, on Microsoft Windows [Versión 10.0.18362.720], locale es-ES) • Flutter version 1.12.13+hotfix.8 at C:\flutter • Framework revision 0b8abb4724 (8 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\LBO880\AppData\Local\Android\Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = C:\Users\LBO880\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.

[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found! Process finished with exit code 0

miguelpruivo commented 4 years ago

@oumi there must be something on your machine that results in this. Maybe gradle version incompatibility? I’m trying to figure what but I can’t seem to be able to replicate the issue as it always builds successfully.

Mind to try the example project provided with the plugin?

Thank you.

miguelpruivo commented 4 years ago

@oumi mind to try the solution described here on the Wiki troubleshooting? Thank you.

phillausofia commented 4 years ago

I have the same issue.

When building the app I get an error specifying that FilePickerDelegate.java uses a deprecated API. And when I want to show the window to select the file, I get the following error:

I/flutter (20357): [FilePicker] Unsupported operation. Method not found. The exception thrown was: MissingPluginException(No implementation found for method ANY on channel file_picker)
E/flutter (20357): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method ANY on channel file_picker)

Plug-in version: 1.6.2 My Flutter version:

Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
    • Flutter version 1.12.13+hotfix.9 at 
    • Framework revision f139b11009 (10 days ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2

In the GeneratedPluginRegistrant.java I can't find the plugin. I tried the solution from the Wiki section, and multiple cleans and builds, but nothing worked.

miguelpruivo commented 4 years ago

@phillausofia looks like you are still invoking FilePicker.ANY instead of FilePicker.any so I believe that this is some cached package issue (from previous versions).

Make sure you are calling using camelCase enum.

phillausofia commented 4 years ago

Eventually I found the glitch:

the previous developer copied the file_picker.dart file from the plugin and added it directly to the code, so all the classes where imported from that file. I've deleted that file and all the previous cached versions of the plug-in (there were quite a few) and now it works.

cavinpabua commented 4 years ago

I have the same problem with Flutter 1.12.13+hotfix.9 and file_picker 1.6.2 . I can't build now

miguelpruivo commented 4 years ago

@cavinpabua post your logs please.

cavinpabua commented 4 years ago

I had a similar a problem, i tried to downgrade the flutter version to 1.12.13+hotfix.8 . But i still have the same error. The result of building with file_picker: ^1.4.0:

Deprecated` Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings 17 actionable tasks: 1 executed, 16 up-to-date

C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:12: error: cannot find symbol import androidx.lifecycle.DefaultLifecycleObserver; ^ symbol: class DefaultLifecycleObserver location: package androidx.lifecycle C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:19: error: cannot find symbol import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter; ^ symbol: class FlutterLifecycleAdapter location: package io.flutter.embedding.engine.plugins.lifecycle C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:35: error: cannot find symbol implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { ^ symbol: class DefaultLifecycleObserver location: class FilePickerPlugin C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:42: error: method does not override or implement a method from a supertype @override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:46: error: method does not override or implement a method from a supertype @override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:50: error: method does not override or implement a method from a supertype @override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:54: error: method does not override or implement a method from a supertype @override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:58: error: method does not override or implement a method from a supertype @override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:63: error: method does not override or implement a method from a supertype @override ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:253: error: cannot find symbol this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); ^ symbol: variable FlutterLifecycleAdapter location: class FilePickerPlugin C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:254: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.addObserver(this.observer); ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:262: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.removeObserver(this.observer); ^ Note: C:\flutter.pub-cache\hosted\pub.dartlang.org\file_picker-1.5.1\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerDelegate.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 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 3s

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

and my flutter doctor output:**

C:\flutter\bin\flutter.bat doctor --verbose [√] Flutter (Channel unknown, v1.12.13+hotfix.8, on Microsoft Windows [Versión 10.0.18362.720], locale es-ES) • Flutter version 1.12.13+hotfix.8 at C:\flutter • Framework revision 0b8abb4724 (8 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\LBO880\AppData\Local\Android\Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = C:\Users\LBO880\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.

[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found! Process finished with exit code 0

I have the exact same logged errors as @oumi but with version 1.6.2

miguelpruivo commented 4 years ago

@cavinpabua this looks like the project needs to me migrated to support v2 (probably that’s a project that started sometime ago). Check the troubleshooting section on the Wiki for Android.

cavinpabua commented 4 years ago

@miguelpruivo I started this project just last month and upon seeing the troubleshooting section all is in order. I have v2 still the error persist. I'm focusing on error: cannot find symbol import androidx.lifecycle.DefaultLifecycleObserver; maybe it gives some lead. maybe this can help

miguelpruivo commented 4 years ago

@cavinpabua this os odd as if it were because of that, it should happen to everyone that uses the plugin (including myself).

Could you please run the example app provided with the package and let me know if it worked for you?

Thank you.

miguelpruivo commented 4 years ago

@cavinpabua after further investigation, and based on your logs, you are using a cached version of 1.5.1. Please, update the plugin to the latest version and see if it still happens for you (you might need to completely remove the cache from your .pub_cache folder).

Also, to all in this thread, please check this answer and see if it helps.

Thank you.

cavinpabua commented 4 years ago

@miguelpruivo I have moved my version to 1.6.2 which is the latest and still got the error below:

C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\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 C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\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 C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:36: error: cannot find symbol implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { ^ symbol: class DefaultLifecycleObserver location: class FilePickerPlugin C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:43: error: method does not override or implement a method from a supertype @Override ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:47: error: method does not override or implement a method from a supertype @Override ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:51: error: method does not override or implement a method from a supertype @Override ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:55: error: method does not override or implement a method from a supertype @Override ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:59: error: method does not override or implement a method from a supertype @Override ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:64: error: method does not override or implement a method from a supertype @Override ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:251: error: cannot find symbol this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); ^ symbol: variable FlutterLifecycleAdapter location: class FilePickerPlugin C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:252: error: incompatible types: FilePickerPlugin.L ifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.addObserver(this.observer); ^ C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:260: error: incompatible types: FilePickerPlugin.L ifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.removeObserver(this.observer); ^ Note: C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerDelegate.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 12 errors

I also have repeatedly deleted the pub.dartlang.org folder manually to ensure clear cache but the error still persist. Am I doing something wrong?

cavinpabua commented 4 years ago

After some investigation with reference to stackoverflow and android jetpack I manually added the following to flutter_file_picker android/build.gradle and reduced the error from 12 to 1 error:

REMAINING ERROR C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\file_picker-1.6.2\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 1 error

ADDED TO BUILD.GRADLE implementation "androidx.lifecycle:lifecycle-runtime:2.2.0" implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.2.0" implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"

miguelpruivo commented 4 years ago

@cavinpabua thank you for the effort. Like I said, you shouldn’t need that dependency at all, otherwise it would be happen to all plugin users including myself since V2 support was added.

We need to dig in the origin cause. Have you checked this?

cavinpabua commented 4 years ago

@miguelpruivo yes my whole project is in androidx now. my project:

android/app/build.gradle compileSdkVersion 28 targetSdkVersion 28

android/gradle.properties org.gradle.jvmargs=-Xmx1536M android.enableR8=true android.useAndroidX=true android.enableJetifier=true

miguelpruivo commented 4 years ago

This is one of those Android mysterious things @cavinpabua, it's not easy specially when I can't replicate it, but I might have found something relevant.

If this is not happening to everyone, leads me to the conclusion that it has to be with Flutter engine itself differences on different versions — and so it seems, like in this open issue.

Basically, some people report to have the same problem with other packages due to some version, and, the one thing that I found in common with all of you on this issue, is that you are running on Windows, while I'm on a Mac, so that's probably something related to the engine + OS platform.

Could you please try to flutter clean then project and then switch to flutter channel master and rebuild it again?

Thank you!

cavinpabua commented 4 years ago

@miguelpruivo Tried flutter clean and flutter channel master with flutter upgrade and upon rebuilding the issue still remains. You mentioned that you're on Mac, I will try to make some virtual machine with Ubuntu Linux and will try to build my project in there. I will get back on this thread.

miguelpruivo commented 4 years ago

@cavinpabua that's quite an effort, but should point us toward the right direction if that works.

Thank you.

cavinpabua commented 4 years ago

@miguelpruivo I took me sometime to setup the environment but the issues still persist. The logs are as follows:

/home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/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/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/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/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:36: error: cannot find symbol implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { ^ symbol: class DefaultLifecycleObserver location: class FilePickerPlugin /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:43: error: method does not override or implement a method from a supertype @Override ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:47: error: method does not override or implement a method from a supertype @Override ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:51: error: method does not override or implement a method from a supertype @Override ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:55: error: method does not override or implement a method from a supertype @Override ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:59: error: method does not override or implement a method from a supertype @Override ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:64: error: method does not override or implement a method from a supertype @Override ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:251: error: cannot find symbol this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); ^ symbol: variable FlutterLifecycleAdapter location: class FilePickerPlugin /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:252: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.addObserver(this.observer); ^ /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:260: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.removeObserver(this.observer); ^ Note: /home/cavin/Downloads/flutter_linux_v1.12.13+hotfix.9-stable/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.6.2/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 12 errors

FAILURE: Build failed with an exception.

miguelpruivo commented 4 years ago

@cavinpabua does that happen when you run the example app from the plugin?

cavinpabua commented 4 years ago

@miguelpruivo aaaaand yeah the example app from the plugin builds without a problem. I just wonder why me and @oumi have the same problem where in fact we just use the plugin as usual. I also want to mention that my project's android language is Kotlin while the example app, I believe, is in Java. Could it be a reason?

miguelpruivo commented 4 years ago

@cavinpabua hum, could it be related? I don't know. But I'll try to create an empty project with Kotlin as Android support and see if I can replicate it (I wish I could, worse that errors, are those that you can't replicate in order to implement a fix).

oumi commented 4 years ago

Sorry for not replying before. Now, i downloaded for the second time the example of @miguelpruivo and it worked without doing anything else (the same example didn't work two weeks before). And i used the last version of file picker on my project also and it worked. I have to say also that i'm using windows. I don't know what's new in this last version... Any way, many thanks guys!!. If you need me to check something to help you to find the problem, tell me please.

miguelpruivo commented 4 years ago

This still looks like cache issues conflicts to me @oumi, which makes it harder to address. Have you updated your Flutter version in the meantime? Thanks!

oumi commented 4 years ago

Actually, last week i tried a lot of things like upgrading gradle (now i have 5.6.4 version) and i don't think that i did anything else. May be the combination of the new version of the plugin and the gradle 5.6.4 worked. Anyway, this is the result of my flutter doctor:

[√] Flutter (Channel unknown, v1.12.13+hotfix.8, on Microsoft Windows [Versión 10.0.18362.778], locale es-ES) • Flutter version 1.12.13+hotfix.8 at C:\flutter • Framework revision 0b8abb4724 (10 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\LBO880\AppData\Local\Android\Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = C:\Users\LBO880\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.

[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

miguelpruivo commented 4 years ago

@cavinpabua would you mind to set your gradle version to 5.6.4 to see if it might be related and actually provide a fix? 🕵️‍♂️

Thanks @oumi.

marchellodev commented 4 years ago

@miguelpruivo The same issue here

[✓] Flutter (Channel beta, v1.17.0, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)

gradle 5.6.4 flutter_file_picker/example works fine

miguelpruivo commented 4 years ago

If example works fine, maybe you can try to see what dependencies have differences on both? Looks like an Android dependencies issue to me.

marchellodev commented 4 years ago

I've switched to 1.4.3+2 and now everything works. I haven't noticed much difference between android folder in example and android folder in my project. The main difference is that my project uses kotlin.

miguelpruivo commented 4 years ago

@marchellodev it looks like this is affecting users with Kotlin projects, I'll keep you updated. Switching to 1.4.3 you'll be losing some of the new features such as multiple file extension filters and so on, but if you don't need them as of now, stick with it for now.

atheist1 commented 4 years ago

I have the similar issue when i add android:requestLegacyExternalStorage="true" this line to Androidmainfest.xml.The logs are as follows:

/Users/qitianle/Desktop/flutter/.pub-cache/hosted/pub.flutter-io.cn/file_picker-1.6.3+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:20: 错误: 找不到符号
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  符号:   类 FlutterLifecycleAdapter
  位置: 程序包 io.flutter.embedding.engine.plugins.lifecycle
1 个错误

FAILURE: Build failed with an exception.

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

@atheist1 also on a Kotlin project?

atheist1 commented 4 years ago

@atheist1 also on a Kotlin project? I am not sure about it, I am a new developer to flutter.
but i guess it is a pure flutter project cause it's created by android studio on start a new flutter project choice.
And its build with no error if i don't add the android:requestLegacyExternalStorage="true" but i can pick pdf file on android Q.

jagmit commented 4 years ago

Joining this thread with the same issue.

What I'm using: ``` file_picker: ^1.8.0+1 ~ $ flutter --version Flutter 1.18.0-9.0.pre.38 • channel master • https://github.com/flutter/flutter.git Framework • revision ffcf1db3ca (11 hours ago) • 2020-04-27 17:41:42 -0700 Engine • revision 4bcfae82c7 Tools • Dart 2.9.0 (build 2.9.0-3.0.dev a69cb6d700) I'm on macOS Catalina 10.15.4 19E287 x86_64 ```
The issue when building my application for android: ``` /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/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 /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/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 /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:36: error: cannot find symbol implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { ^ symbol: class DefaultLifecycleObserver location: class FilePickerPlugin /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:43: error: method does not override or implement a method from a supertype @Override ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:47: error: method does not override or implement a method from a supertype @Override ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:51: error: method does not override or implement a method from a supertype @Override ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:55: error: method does not override or implement a method from a supertype @Override ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:59: error: method does not override or implement a method from a supertype @Override ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:64: error: method does not override or implement a method from a supertype @Override ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:253: error: cannot find symbol this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); ^ symbol: variable FlutterLifecycleAdapter location: class FilePickerPlugin /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:254: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver this.lifecycle.addObserver(this.observer); ^ /Users/jagmit/dev/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.8.0+1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:262: 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 4s Exception: The plugin file_picker could not be built due to the issue above. ```

What I've already checked/tried:

I'm on macOS so I don't think the issue lies here. My MainActivity is in Kotlin so this might be a hint.

@miguelpruivo any direction where we could investigate this further?

miguelpruivo commented 4 years ago

@jagmit if I have the time, today I'll create a sample project with Kotlin and see if I can replicate it. If so, then that's the main lead. I'll keep in touch.

jagmit commented 4 years ago

Just tried with transforming my MainActivity from Kotlin to Java and the issue is still there. Same with pointing my manifest directly to the FlutterActivity coming from Flutter itself like:

<activity
            android:name="io.flutter.embedding.android.FlutterActivity"
            ....
miguelpruivo commented 4 years ago

@jagmit I believe that it must be some config property, we just need to find which one. Because running the plugin on Java projects works just fine.

miguelpruivo commented 4 years ago

Ok, so, basically I created an empty project (with Kotlin support) and was able to immediately build without an error at all (compileSdk: 29) both with android:requestLegacyExternalStorage="true" and not.

minSdkVersion 21
targetSdkVersion 29

So, here my files and please, anyone in this thread, can compare and see if anything helps:

gradle.version=5.6.2

android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
miguelpruivo commented 4 years ago

Any news on this?

atheist1 commented 4 years ago

Any news on this? It's works fine if i do not add add android:requestLegacyExternalStorage="true"

miguelpruivo commented 4 years ago

@atheist1 on which version? Then don’t add it at all. That’s only for Android Q versions when your buildSdk is set to 29.