Google Gemini API inference for CodeOnTheGo's AI plugins. Registers itself as the
gemini backend with ai-core's LlmInferenceService, which is
what ai-core's Agent chat, code-suggestions-plugin, speech-to-text-plugin and
vector-search-plugin actually talk to.
Calls the Generative Language REST API directly over HttpURLConnection rather
than the google-genai SDK: the SDK bundles OkHttp 4.x, but plugins run in the
host IDE's classloader where okhttp3 resolves to the host's older OkHttp, and
that mismatch crashed generation with a NoSuchMethodError.
Prerequisites: Android SDK (API 33+), JDK 17. Create local.properties with
sdk.dir=.... This plugin uses the shared wrapper at the repo root:
cd ai-agent-gemini
../gradlew assemblePlugin # release -> build/plugin/ai-agent-gemini.cgp
../gradlew assemblePluginDebug # debug variantThe key is entered in AI Core → Agent settings, not here. It is stored
encrypted (AES/GCM under a hardware-backed Android Keystore secret) and sent as
an x-goog-api-key header, never in a URL query string.
security/SecureApiKeyStore.kt is the only copy of the crypto — this plugin owns
both the write and the read, so there are no constants to keep in sync with
another plugin. A key written under an earlier plugin id is adopted once by
preferences/GeminiPreferences.kt and re-encrypted here.
Install ai-core as well — without the router this plugin has nothing to
register with. Order does not matter: this plugin re-registers when it sees
ai-core activate. Copy build/plugin/ai-agent-gemini.cgp to the device, install
via CodeOnTheGo's Plugin Manager, then restart the IDE.
This plugin's own settings pane calls GeminiBackend.listModels() and
listModels(String) directly (see BackendGeminiCatalogGateway in
settings/GeminiCatalogGateway.kt) to populate the model picker and to verify a
key before it is saved. Those two signatures, and the ListModels HTTP <code>
message shape thrown by fetchAvailableModels, are a contract — the pane is
mounted by ai-core across the plugin classloader boundary, so
proguard-rules.pro pins the class and its public methods.
Every source file sits in a package named for its layer; nothing is loose at the
root of com/itsaky/androidide/plugins/aiagentgemini/.
plugin/GeminiPlugin.kt— plugin entry point; registers the backend with ai-corebackend/GeminiBackend.kt— the REST transport, streaming (SSE) and model catalogerrors/GeminiErrorFormatter.kt— turns an API failure into one translated sentencesecurity/SecureApiKeyStore.kt— AES/GCM at restpreferences/GeminiPreferences.kt— this plugin's settings store, plus the one-time adoption of settings written under earlier plugin idsprompt/GeminiSystemPrompt.kt— the system prompt this cloud model is givenlogging/—LOG_PREFIX(AiAgentGemini), prefixing every logcat tag this plugin writessettings/— the settings pane this backend contributes to the selector
GPL-3.0 — same as AndroidIDE / CodeOnTheGo.