You clone a Flutter project, run flutter run, and get a wall of red text. The tempting move is to paste the last line into a search engine. Usually that's the slow route.
Most first-build failures on a project someone else wrote don't come from the code. They come from the setup: a Flutter version below the project's minimum, the wrong Java, a missing SDK, or generated files that were never generated. A fixed triage order clears most of them before you ever need the exact error message.
Run each step from the project root, and retry the build after every step. If it works, stop.
Step 1: Ask flutter doctor first
flutter doctor -v
Fix anything it flags before building. The -v flag matters: it prints the path after Java binary at:, so you can see which Java Flutter actually uses. That one line explains a lot of Gradle errors that look like they're about something else.
Step 2: Compare your Flutter version with the project's minimum
flutter --version
Check it against the minimum in the project's README or setup guide. If you're below it, upgrade:
flutter upgrade
A version that's too old often shows up as a pub error rather than a build error, for example:
The current Dart SDK version is X, requires ^3.9.2
Other forms of the same problem: "SDK constraint" errors and "Version solving failed". The fix is the same in every case: flutter upgrade, then flutter clean && flutter pub get.
Step 3: Build Android with Java 17
Android builds expect JDK 17 or newer. In Android Studio, go to Settings > Build Tools > Gradle > Gradle JDK and pick 17 or newer. From the terminal you can point Flutter at a specific JDK:
flutter config --jdk-dir "path/to/jdk17"
Gradle failures read differently on every machine, but the usual cause is the same: an old Android Studio or a Gradle JDK below 17. Our recent templates use Android Gradle Plugin 9 with Gradle 9, and a project on that setup needs a current toolchain. So if sync fails, update Android Studio to the latest stable version, check this setting again and run flutter clean before you read the stack trace.
Step 4: Clean and fetch packages
flutter clean
flutter pub get
This clears stale build output and restores dependencies. It's cheap, so it belongs early in the order.
Step 5: Generate code if a .g.dart file is missing
Projects that use Hive CE or Isar rely on generated adapters. If the compiler complains about a missing .g.dart file or an undefined registerAdapters, the code generator hasn't run yet:
dart run build_runner build --delete-conflicting-outputs
Depending on the project, you may need it on a fresh download, and you need it again every time you change a model.
Step 6 (iOS only): Install pods
cd ios && pod install && cd ..
If CocoaPods itself errors, the usual cause is stale pods or an outdated local spec repo. Reset them:
cd ios
rm -rf Pods Podfile.lock
pod repo update
pod install
cd ..
If the error mentions a deployment target, make sure the platform line in ios/Podfile matches the project's iOS minimum (for example platform :ios, '14.0'), then run pod install again.
Still failing? Now read the message
After those six steps, the leftovers are specific and quick to recognise:
| Message | Cause | Fix |
|---|---|---|
| No Android SDK found | Android Studio missing, or SDK in a custom folder | Install the SDK and command-line tools, run flutter doctor --android-licenses, or flutter config --android-sdk <path>
|
| Gradle runs out of memory |
org.gradle.jvmargs too high for your machine |
Lower it in android/gradle.properties, for example -Xmx4G
|
| Namespace not specified | App ID changed, Android files disagree | Match namespace and applicationId, move MainActivity.kt and fix its package line |
| Signed with the debug key |
android/key.properties not found |
Create the upload keystore and key.properties
|
| Building with plugins requires symlink support | Windows without Developer Mode |
start ms-settings:developers, turn it on, flutter pub get
|
app_localizations.dart not found |
Translations not generated |
flutter pub get or flutter gen-l10n
|
One more Gradle gotcha: an error can name a plugin when the real problem is your JDK. That's why Java sits at Step 3 and not at the end.
Why the order matters
Each step is cheaper than the one after it, and each removes a whole class of errors. Guessing from the last line of a stack trace skips that, and every wrong guess costs you another full build. Work the list top to bottom and the error that's left, if any, is usually the real one.
Further reading: Flutter Build Errors After Purchase: Troubleshooting Guide.
Which build error cost you the most time on a project you didn't write, and what turned out to be the cause?
Top comments (1)
Good order, and putting Java before the stack trace is exactly right. Two things I'd add to step 6 from cloning other people's Flutter apps on a Mac:
flutter build ios --config-only(or oneflutter runfor iOS) beforepod install. On a fresh cloneios/Flutter/Generated.xcconfigdoesn't exist yet, andpod installfails with a message aboutFLUTTER_ROOTor a missingGenerated.xcconfigthat looks like a CocoaPods problem but isn't.pod installdies inside Ruby with anffierror, it's usually the system Ruby.brew install cocoapods(or a Ruby from rbenv) fixes it faster than any pod cleanup.And the one that cost me the most time on someone else's project: an
IPHONEOS_DEPLOYMENT_TARGETset per pod lower than the Podfile platform, which only failed on archive, not onflutter run. A smallpost_installhook that sets every pod target to the app's minimum made it go away.