flutter_agent_kit_android 0.0.1
flutter_agent_kit_android: ^0.0.1 copied to clipboard
The Android implementation of flutter_agent_kit — bridges to Google's real ADK-Kotlin engine on-device.
The Android implementation of flutter_agent_kit — a real bridge to ADK-Kotlin, not a reimplementation of it.
You should not need to depend on this package directly; add flutter_agent_kit to your app instead, and this package comes along as its Android implementation automatically.
What this package does #
- Implements
flutter_agent_kit_platform_interface'sFlutterAgentKitHostApiby constructing a real ADK-KotlinLlmAgentandPublisherRunnerper configured agent. - Bridges each Dart-defined
AgentToolto a realBaseFutureTool, round-tripping a tool call through Pigeon to Dart and back. - Maps ADK-Kotlin's
Eventstream to this plugin's wire event types, with real SSE streaming (RunConfig(streamingMode = StreamingMode.SSE)) — not one blocking call per turn. - Wires both model backends: Firebase AI (cloud) and LiteRT-LM (on-device).
Setup requirements #
These come from ADK-Kotlin's and Firebase's own floors, found by attempting a real build rather than trusted from documentation that can go stale:
compileSdk 37,minSdk 26,jvmToolchain(17)in your app'sandroid/app/build.gradle.kts.- A standard META-INF packaging conflict (
google-auth/api-common, common to any Firebase-AI-consuming app) needs:android { packaging { resources { excludes += setOf( "META-INF/INDEX.LIST", "META-INF/DEPENDENCIES", "META-INF/LICENSE", "META-INF/LICENSE.txt", "META-INF/NOTICE", "META-INF/NOTICE.txt", ) } } }
If you use AgentModelConfig.cloud() #
- Create a Firebase project and register your Android app, placing
google-services.jsonatandroid/app/. - Apply the Google Services Gradle plugin —
google-services.jsondoes nothing without it:// android/settings.gradle.kts plugins { id("com.google.gms.google-services") version "4.5.0" apply false } // android/app/build.gradle.kts plugins { id("com.google.gms.google-services") } - In the Firebase console, go to AI Services → AI Logic, click Get started, and choose Gemini Developer API (free tier, no billing) — walk through every screen, not just the first. Skipping this produces
The Firebase AI SDK requires the Vertex AI in Firebase API, which reads like a code problem but isn't one. - That same flow also configures App Check. If you see
Firebase App Check token is invalidand your app doesn't integrate an App Check provider, set enforcement to Unenforced (monitoring only) for the Firebase AI Logic API in the console's App Check section. After changing this, fully stop and relaunch the app rather than retrying — the SDK appears to cache the enforcement state for the life of the process, so a change won't be visible until a fresh launch.
If you use AgentModelConfig.onDevice() #
Supply a LiteRT-LM model file and its path via modelPath. No Firebase project needed. LiteRT-LM (not ML Kit) is used specifically because it's the only on-device backend that supports tool calling — see docs/adk-kotlin-capability-map.md, Tier 4.
Testing #
This package's native logic is covered by real JVM unit tests (./gradlew :flutter_agent_kit_android:testDebugUnitTest), including an integration test that runs a real LlmAgent and a real tool round-trip through the actual generated Pigeon codec — no device or Flutter engine required. What isn't and can't be unit-tested (a real network call to Firebase, a real on-device model) is verified by hand against flutter_agent_kit/example; see docs/v1-implementation-plan.md's review log for the full verification history.