"Flutter Android build fails on every plugin with 'Unresolved reference Registrar' despite all cleaning attempts"


I'm at my wit's end with a Flutter project. For days, I've been unable to build the Android version. Every time I fix one plugin, the build fails on the next one with the same error: Unresolved reference 'Registrar'. The latest one is :speech_to_text.

This is everything I've already tried:

  1. Project Reconstruction: My entire android folder was corrupted. I deleted it and recreated it from scratch using flutter create .. My project now uses the modern v2 embedding and has clean, standard Gradle files (settings.gradle.kts, build.gradle.kts).

  2. Environment Check: flutter doctor -v shows NO ISSUES. My Flutter SDK is clean, my Android toolchain is perfect, licenses are accepted.

  3. Gradle Cache Purge: I completely deleted the entire C:\Users\YourUser\.gradle folder and let Gradle redownload everything from scratch. The build still failed.

  4. Dependencies Upgrade: I've run flutter pub upgrade to get the latest versions of all my packages. I've also tried updating them manually in pubspec.yaml. The error persists.

  5. Pub Cache Repair: I've run dart pub cache repair to fix any corruption in the central package cache. The error persists.

  6. Code/Plugin Analysis: The error always points to a plugin (like speech_to_text, permission_handler, etc.) and a reference to Registrar, which is from the old v1 embedding.

I don't understand how this is possible. My project is v2, my Flutter environment is v2, but the plugins are still compiling as if they were in a v1 project. I have fought this for days and I am completely lost.

Here is my latest build failure log:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... Running Gradle task 'assembleDebug'... warning: [options] source value 8 is obsolete and will be removed in a future release warning: [options] target value 8 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 3 warnings e: file:///C:/Users/Mack/AppData/Local/Pub/Cache/hosted/pub.dev/speech_to_text-6.6.2/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt:37:48 Unresolved reference 'Registrar'. e: file:///C:/Users/Mack/AppData/Local/Pub/Cache/hosted/pub.dev/speech_to_text-6.6.2/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt:139:37 Unresolved reference 'Registrar'. e: file:///C:/Users/Mack/AppData/Local/Pub/Cache/hosted/pub.dev/speech_to_text-6.6.2/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt:141:54 Unresolved reference 'activity'. e: file:///C:/Users/Mack/AppData/Local/Pub/Cache/hosted/pub.dev/speech_to_text-6.6.2/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt:142:23 Unresolved reference 'addRequestPermissionsResultListener'. e: file:///C:/Users/Mack/AppData/Local/Pub/Cache/hosted/pub.dev/speech_to_text-6.6.2/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt:143:55 Unresolved reference 'context'. e: file:///C:/Users/Mack/AppData/Local/Pub/Cache/hosted/pub.dev/speech_to_text-6.6.2/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt:143:76 Unresolved reference 'messenger'. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':speech_to_text:compileDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 5m 30s Error: Gradle task assembleDebug failed with exit code 1
2
Feb 24 at 4:15 AM
User AvatarJavier Sarrion Frias
#android#flutter#kotlin#android-gradle-plugin#speech-to-text

No answer found for this question yet.