fluttergradlepubspec.yaml

Execution failed for task ':file_picker:compileDebugJavaWithJavac'


The error I keep getting while building my flutter project.

Package file_picker:linux references file_picker:linux as the default plugin, but it does not provide an inline implementation.
Ask the maintainers of file_picker to either avoid referencing a default implementation via `platforms: linux: default_package: file_picker` or add an inline implementation to file_picker via `platforms: linux:` `pluginClass` or `dartPluginClass`.

Package file_picker:macos references file_picker:macos as the default plugin, but it does not provide an inline implementation.
Ask the maintainers of file_picker to either avoid referencing a default implementation via `platforms: macos: default_package: file_picker` or add an inline implementation to file_picker via `platforms: macos:` `pluginClass` or `dartPluginClass`.

Package file_picker:windows references file_picker:windows as the default plugin, but it does not provide an inline implementation.
Ask the maintainers of file_picker to either avoid referencing a default implementation via `platforms: windows: default_package: file_picker` or add an inline implementation to file_picker via `platforms: windows:` `pluginClass` or `dartPluginClass`.

/Users/user/.pub-cache/hosted/pub.dev/file_picker-6.2.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:122: error: cannot find symbol
    public static void registerWith(final io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
                                                                                 ^
  symbol:   class Registrar
  location: interface PluginRegistry
/Users/user/.pub-cache/hosted/pub.dev/file_picker-6.2.1/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:251: error: cannot find symbol
            final PluginRegistry.Registrar registrar,
                                ^
  symbol:   class Registrar
  location: interface PluginRegistry
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':file_picker:compileDebugJavaWithJavac'.

> Compilation failed; see the compiler error output for details.

I have tried flutter pub cache clean ,flutter clean and running flutter run again but it results in the same error.

Checked out on StackOverflow others also faced similar problems with other packages but there was no appropriate solution or problem explained.


Solution

  • Ok so I fixed it. It was only happening because the file_picker dependency was outdated in my project. It resolved when I updated the version. It was earlier 6.1.1 and I upgraded it to 9.0.0.

    Don't know what exactly was breaking it but it got fixed.