1

Here is my pubspec.yaml
When I run pub get without image picker, it works.

name: project1
description: A new Flutter application.

publish_to:
version: 1.0.0+1

environment:
  sdk:  ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  camera:
  image_picker: ^0.6.1+4


  image_cropper:
  path_provider:
  path:
  flutter_local_notifications: ^1.4.4+2
  cupertino_icons: ^0.1.3


dev_dependencies:
  flutter_test:
    sdk: flutter


flutter:

 uses-material-design: true
 assets:

But when I include image_picker from latest version to 0.6.0 it shows the same error message

The plugin flutter_plugin_android_lifecycle doesn't have a main class defined in C:\Users\john\Documents\flutter_windows_1.17.1-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.8\android\src\main\java\io\flutter\plugins\flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.java or C:\Users\john\Documents\flutter_windows_1.17.1-stable\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.8\android\src\main\kotlin\io\flutter\plugins\flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.kt. This is likely to due to an incorrect androidPackage: io.flutter.plugins.flutter_plugin_android_lifecycle or mainClass entry in the plugin's pubspec.yaml. If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.

I tried running other projects w/o image_picker and they seem to work fine. I just can't install the image_picker.

Jon
  • 23
  • 1
  • 5

3 Answers3

0

I tried importing in Flutter 1.17.5 • channel stable. It's working fine. Can you upgrade flutter and try again?

0

Delete .pub-cache folder

Run flutter pub get command

If this doesn't work try

Adding flutter_plugin_android_lifecycle dependency in your yaml file

delete .pub-cache folder

run flutter pub get command

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ritesh
  • 533
  • 2
  • 7
  • 18
0

Adding flutter_plugin_android_lifecycle dependencies and running

dart pub cache repair

or

flutter pub cache repair

worked for me.

doneforaiur
  • 1,308
  • 7
  • 14
  • 21