Summary
whisper_cpp_flutter_plus 0.4.1 fails to build on Android with modern Flutter app templates (Kotlin DSL / settings.gradle.kts with dev.flutter.flutter-plugin-loader). The app's javac fails with:
error: cannot find symbol
import com.skynodigital.whisper_cpp_flutter.WhisperCppFlutterPlugin;
in GeneratedPluginRegistrant.java.
Root cause
The plugin ships a Kotlin source file:
android/src/main/kotlin/com/skynodigital/whisper_cpp_flutter/WhisperCppFlutterPlugin.kt
but android/build.gradle only applies the Android library plugin:
apply plugin: 'com.android.library'
The kotlin-android (org.jetbrains.kotlin.android) plugin is never applied, so the Kotlin source set is never compiled and WhisperCppFlutterPlugin.class does not exist in the library's output. When the host app's GeneratedPluginRegistrant.java references the class, compilation fails.
Note the build script even configures KotlinCompile tasks (tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile)), but with no Kotlin plugin applied there are zero such tasks, so that block is a silent no-op.
This likely goes unnoticed in older android/app templates where the app-level Kotlin plugin leaked configuration, but with current Flutter templates (tested on Flutter 3.41.6 stable) the plugin subproject is evaluated in isolation and the bug always reproduces.
Steps to reproduce
flutter create repro with a current stable Flutter (3.41.x — Kotlin DSL Android template).
- Add
whisper_cpp_flutter_plus: ^0.4.1 to pubspec.yaml, flutter pub get.
flutter build apk --debug.
Result:
GeneratedPluginRegistrant.java: error: cannot find symbol
import com.skynodigital.whisper_cpp_flutter.WhisperCppFlutterPlugin;
Environment
- whisper_cpp_flutter_plus: 0.4.1
- Flutter: 3.41.6 (stable channel)
- AGP (from the plugin's buildscript): 8.7.3
- Host app: default Flutter Kotlin DSL template (
settings.gradle.kts + dev.flutter.flutter-plugin-loader)
Suggested fix
In android/build.gradle, apply the Kotlin plugin next to the library plugin:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
Since the build script pins KotlinCompile to JVM target 11, it should also align compileOptions (AGP's javac still defaults to 1.8, and Kotlin/Java jvm-target mismatch fails the build on recent Kotlin versions):
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
Workaround (app side)
Until a fixed release is published, this in the app's root android/build.gradle.kts makes 0.4.1 build:
subprojects {
if (name == "whisper_cpp_flutter_plus") {
plugins.withId("com.android.library") {
apply(plugin = "org.jetbrains.kotlin.android")
}
// The plugin pins KotlinCompile to JVM 11 while AGP's javac default
// stays at 1.8 — align the Java targets to match.
plugins.withId("com.android.library") {
extensions.configure<com.android.build.gradle.LibraryExtension>("android") {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
}
}
}
Thanks for the package — live on-device transcription works great once the build is unblocked.
Summary
whisper_cpp_flutter_plus0.4.1 fails to build on Android with modern Flutter app templates (Kotlin DSL /settings.gradle.ktswithdev.flutter.flutter-plugin-loader). The app'sjavacfails with:in
GeneratedPluginRegistrant.java.Root cause
The plugin ships a Kotlin source file:
but
android/build.gradleonly applies the Android library plugin:The
kotlin-android(org.jetbrains.kotlin.android) plugin is never applied, so the Kotlin source set is never compiled andWhisperCppFlutterPlugin.classdoes not exist in the library's output. When the host app'sGeneratedPluginRegistrant.javareferences the class, compilation fails.Note the build script even configures
KotlinCompiletasks (tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile)), but with no Kotlin plugin applied there are zero such tasks, so that block is a silent no-op.This likely goes unnoticed in older
android/apptemplates where the app-level Kotlin plugin leaked configuration, but with current Flutter templates (tested on Flutter 3.41.6 stable) the plugin subproject is evaluated in isolation and the bug always reproduces.Steps to reproduce
flutter create reprowith a current stable Flutter (3.41.x — Kotlin DSL Android template).whisper_cpp_flutter_plus: ^0.4.1topubspec.yaml,flutter pub get.flutter build apk --debug.Result:
Environment
settings.gradle.kts+dev.flutter.flutter-plugin-loader)Suggested fix
In
android/build.gradle, apply the Kotlin plugin next to the library plugin:Since the build script pins
KotlinCompileto JVM target 11, it should also aligncompileOptions(AGP'sjavacstill defaults to 1.8, and Kotlin/Java jvm-target mismatch fails the build on recent Kotlin versions):android { compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } }Workaround (app side)
Until a fixed release is published, this in the app's root
android/build.gradle.ktsmakes 0.4.1 build:subprojects { if (name == "whisper_cpp_flutter_plus") { plugins.withId("com.android.library") { apply(plugin = "org.jetbrains.kotlin.android") } // The plugin pins KotlinCompile to JVM 11 while AGP's javac default // stays at 1.8 — align the Java targets to match. plugins.withId("com.android.library") { extensions.configure<com.android.build.gradle.LibraryExtension>("android") { compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } } } } }Thanks for the package — live on-device transcription works great once the build is unblocked.