🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

Flutter “Error When Reading bin/main.dart” – Causes & Solutions

Uncategorized

How to Fix the Flutter Error: “Error when reading bin/main.dart: No such file or directory”

Flutter is one of the most popular frameworks for building beautiful and fast cross-platform mobile apps. However, developers—especially beginners—often run into confusing errors after cloning a project from GitHub or when switching machines.

One such error is:

Error when reading '.../bin/main.dart': No such file or directory.

At first glance, this looks scary. But don’t worry—your Flutter project is not broken. This error has a simple and quick fix. In this article, you’ll understand why this happens and learn three easy methods to resolve it.


⭐ Why This Error Happens

Flutter projects always start executing from:

lib/main.dart

This file is the official entry point for every Flutter application.

But in some cases—especially when you clone a project—Android Studio or VS Code mistakenly tries to start the app from:

bin/main.dart

The problem?
Most Flutter projects do not have a bin folder at all, so Flutter throws an error saying the file does not exist.

This issue usually arises because:

  • The previous developer used a custom run configuration
  • Old IDE metadata was committed to Git
  • The project was renamed or moved
  • Android Studio cached an outdated entry point

The good news? The fix is extremely simple.


Solution 1: Run Your Project Using the Correct Entry Point

The fastest way to bypass this error is by running Flutter with an explicit target file.

Just open your terminal and run:

flutter run -t lib/main.dart

Here:

  • -t stands for target
  • You are telling Flutter exactly which file should be used as the entry point

If your lib/main.dart exists (and it almost always does), your app will launch instantly.


🔧 Solution 2: Fix the Entry Point Inside Android Studio

If you want a permanent fix inside the IDE, follow these steps:

Step 1: Open Android Studio


Step 2: Navigate to

Run → Edit Configurations

Step 3: Select Your Flutter Run Configuration

You will see something like:

Dart entrypoint: bin/main.dart

Step 4: Change it to

lib/main.dart

Step 5: Click Apply → OK

Now try running the project again.
The error will disappear instantly.


🗑 Solution 3: Delete Wrong Run Configuration Files

Sometimes the incorrect configuration is stored inside the project’s .idea folder, which gets cloned along with the project.

To fix this:

  1. Go to your project directory
  2. Open:
.idea/runConfigurations/
  1. Delete the file:
main_dart.xml

This forces Android Studio to recreate a fresh, correct configuration pointing to:

lib/main.dart

🔍 How to Verify Your Flutter Project Structure

Before applying any fix, it’s smart to quickly check if your project has the correct structure.

Run this command in your project folder (Windows):

tree /F

The correct Flutter structure always includes:

lib/
   main.dart   ← entry point
pubspec.yaml
android/
ios/
web/

If lib/main.dart exists, you’re good to go.


🧠 Summary: Why This Error Happens & How to Fix It

IssueWhy It HappensSolution
Flutter tries to load bin/main.dartWrong run configuration from IDEPoint entry to lib/main.dart
App fails after cloning project.idea metadata from previous devRun flutter run -t lib/main.dart
IDE using old configCached run configurationDelete main_dart.xml

🚀 Final Thoughts

This error may look intimidating, but the fix is extremely simple. The problem is not your code, not your Flutter SDK, and not your project structure—it’s just the IDE pointing to the wrong file.

Whenever you see:

Error when reading bin/main.dart

Remember the one-line fix:

flutter run -t lib/main.dart

It works every time.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x