Flutter build fails because the Android project uses the v1 embedding
Build failed due to use of deprecated Android v1 embeddingShort answer
Your Android project was made before Flutter 1.12 and still uses the v1 embedding, while the plugins you use need v2. Add the flutterEmbedding meta-data with value 2 to AndroidManifest.xml, make MainActivity extend the v2 FlutterActivity, and drop the old FlutterApplication class. Then rebuild.
Fix it fast
1Find out which cause you have
Look for the v1 signs in the Android project: the old application class and an activity that imports io.flutter.app.
grep -rn "io.flutter.app\|flutterEmbedding\|GeneratedPluginRegistrant" android/app/src/main2Match what you see, then jump to its fix
- 1
No flutterEmbedding entry, or android:name="io.flutter.app.FlutterApplication" on the application tagThe manifest does not declare the v2 embeddingFix - 2
MainActivity imports io.flutter.app.FlutterActivity or calls GeneratedPluginRegistrant.registerWith(this) in onCreateMainActivity extends the old FlutterActivity or registers plugins by handFix - 3
Calls to FlutterMain.startInitialization, or imports from io.flutter.facadeAn add-to-app module still uses FlutterMain or the facade packageFix
- 1
What does the error look like?
Build failed due to use of deprecated Android v1 embedding
Cause 1 of 3
The manifest does not declare the v2 embedding
1Check
Open the manifest and look inside the application element.
cat android/app/src/main/AndroidManifest.xml2Fix
Replace the old application name with the placeholder and add the embedding flag inside application.
<application
android:name="${applicationName}">
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>3Verify
Build the app.
flutter build apk --debugConfirmed by github.com
Cause 2 of 3
MainActivity extends the old FlutterActivity or registers plugins by hand
1Check
Print MainActivity and read its imports and onCreate.
cat android/app/src/main/*/*/*/MainActivity.* 2>/dev/null || find android/app/src/main -name 'MainActivity.*'2Fix
Extend the v2 FlutterActivity and delete the onCreate override. FlutterActivity registers plugins itself when the engine is created. If you add custom platform channels, set them up in configureFlutterEngine and call GeneratedPluginRegistrant.registerWith(flutterEngine) there.
// MainActivity.kt
import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity()3Verify
Run the app on a device or emulator.
flutter runConfirmed by github.com
Cause 3 of 3
An add-to-app module still uses FlutterMain or the facade package
1Check
Search the host Android app that embeds Flutter.
grep -rn "FlutterMain\|io.flutter.facade" android/ .2Fix
Remove the FlutterMain initialisation calls, since Flutter initialises itself. Use io.flutter.embedding.android.FlutterFragment in place of io.flutter.facade.FlutterFragment, or FlutterView from the embedding package when you need a view.
// replace io.flutter.facade.FlutterFragment with
import io.flutter.embedding.android.FlutterFragment3Verify
Rebuild the host app.
./gradlew assembleDebugConfirmed by github.com
How do I stop it coming back?
- Do not hand-edit generated files such as GeneratedPluginRegistrant; call it only from configureFlutterEngine when you must.
- Compare your android folder with a fresh flutter create project when you upgrade Flutter by several versions.
- Let FlutterActivity register plugins instead of doing it in onCreate.
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
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 fixMobile apps
Android resource linking fails with resource android:attr/lStar not found
error: failed linking references.
The lStar attribute exists only from Android API 31.
2 causes, each with a fix