2

Please don't mark as a duplicate. I have tried to read this Flutter : Target file "lib/main.dart" not found but I have found no answer, because what I ask will be little different

so I have this error when I run my Flutter App through the Android project (from Android Studio), I mean for some reason I did not run the project through the Flutter project (not from VS Code). I have no issue If run my Flutter app through VS Code

this is the error

Error: Error when reading 'lib/main.dart': No such file or directory import 'package:mobile/main.dart' as entrypoint

so basically the Android Studio can't find the main.dart.

I implement Flavor on my Flutter, so I have several main functions such as main_production.dart, main_staging.dart and main_development.dart instead of normal main.dart . thats why the system can't find the entry point.

In iOS Xcode, I can set the main entry point through Flutter Target like this

enter image description here

but now I am confused, how to connect my Android project to the several main function (my dart files)

Alexa289
  • 8,089
  • 10
  • 74
  • 178

1 Answers1

1

In android studio, open action menu with (cmd+shift+a on mac and ctrl+shift+a on windows/linux) and select Edit configurations

enter image description here

Then, using a plus sign at the top, add a new flutter run config

enter image description here

And specify an appropriate entrypoint and flavor:

enter image description here

All that's left is to run the new config using either of the green buttons at the top (run or debug)

enter image description here

eeqk
  • 3,492
  • 1
  • 15
  • 22
  • 1
    thanks for the answer, but I am really sorry, this is not what I am looking for. as I said, I have no issue if I run the app in VSCode. but for some reason now I need to run only the Android project only, not the flutter project – Alexa289 Apr 29 '22 at 01:28
  • Sorry for not paying enough attention, I've changed my answer - please have a look if it's what you need – eeqk Apr 29 '22 at 10:35