Flutter Android build fails because the app has too many methods
Too many field references: 131000; max is 65536.Short answer
One DEX file can reference at most 65,536 methods. Large plugins can pass that. If minSdk is 21 or higher, multidex is built in and the error should not appear. For a lower minSdk, either raise minSdk or enable multidex: Flutter offers to do it when you run a debug build, or you set multiDexEnabled in Gradle.
Fix it fast
1Find out which cause you have
Open the app module's Gradle file and read the minSdk line. It tells you which cause applies: the value is a number, or it comes from flutter.minSdkVersion.
grep -n -i "minSdk\|multiDex" android/app/build.gradle*2Match what you see, then jump to its fix
What does the error look like?
Too many field references: 131000; max is 65536.You may try using --multi-dex option.method ID not in [0, 0xffff]: 65536
Cause 1 of 2
minSdk is 20 or lower, so multidex is not automatic
1Check
Android 5.0 (API 21) and newer load several DEX files natively, so multidex is on by default there. Below that, one DEX file per APK is the rule.
grep -n -i "minSdk" android/app/build.gradle*2Fix
If you can drop Android 4.4 and older, raise minSdk to 21. That removes the limit without any library. Flutter's template reads the value from flutter.minSdkVersion, and you can replace it with a number.
// android/app/build.gradle.kts
defaultConfig {
minSdk = 21
}3Verify
A clean build finishes without the field references error.
flutter clean
flutter build apk --debugConfirmed by developer.android.com
Cause 2 of 2
You must keep an old minSdk and have to enable multidex yourself
1Check
Flutter's tool can opt a project in. When you run a debug build on an Android device and it asks about multidex, answering yes lets Flutter add androidx.multidex and a generated FlutterMultiDexApplication.
flutter run --debug2Fix
Answer y to the multidex prompt. To do it in Gradle by hand, set multiDexEnabled and add the multidex library, as the Android docs show.
// android/app/build.gradle.kts
android {
defaultConfig {
multiDexEnabled = true
}
}
dependencies {
implementation("androidx.multidex:multidex:2.0.1")
}3Verify
The app builds and starts on the old device or emulator.
flutter build apk --debugConfirmed by docs.flutter.dev
How do I stop it coming back?
- Set minSdk to 21 unless you really need older phones.
- Review large plugins before adding them; each one adds methods.
- Keep R8 code shrinking on for release builds.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Flutter Android build stops with Execution failed for task ':app:…'
Execution failed for task ':app:compileFlutterBuildRelease'.
The line only tells you which Gradle step broke; the task name in the quotes tells you why.
5 causes, each with a fixMobile apps
Google Play says the app does not support 16 KB memory pages
check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a
Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.
5 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Android install error: the package conflicts with an existing package of the same name
The package conflicts with an existing package by the same name
Android allows only one app per application ID, and an update must be signed with the same certificate as the installed version.
3 causes, each with a fix