Skip to content

Android build fails on modern Flutter templates: 'kotlin-android' plugin not applied, GeneratedPluginRegistrant cannot find WhisperCppFlutterPlugin #1

Description

@projectsrised

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

  1. flutter create repro with a current stable Flutter (3.41.x — Kotlin DSL Android template).
  2. Add whisper_cpp_flutter_plus: ^0.4.1 to pubspec.yaml, flutter pub get.
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions