wrkm.app
Search
Mobile Development

AppFunctions 1.0 Is Stable: Turning Your Android App Into a Tool for AI Agents

AppFunctions 1.0 Is Stable: Turning Your Android App Into a Tool for AI Agents

Editor
Nov 30, 2026 · 8 min read
AppFunctions 1.0 Is Stable: Turning Your Android App Into a Tool for AI Agents

How Jetpack AppFunctions works, what it takes to ship one, and what changed on the road from alpha to stable.On November 18, 2026, Jetpack shipped androidx.appfunctions 1.0.0, the first stable release. The release notes are short: “Version bump to Stable.” The road there was not. It took 13 alphas, a beta and a release candidate over about 18 months, starting with alpha01 in May 2025.If you skipped the alphas, this post covers what AppFunctions is, how the pieces fit, and what you need to add one to your app.What AppFunctions isAppFunctions is an Android platform API paired with a Jetpack library. Google’s docs describe it as letting your app act “like on-device MCP servers.” You expose specific features of your app as functions. Agents such as Gemini can discover them, read what they do, and call them.For example, “Create a task called Buy milk“ can be handled by an assistant calling your app’s createTask function directly. Nobody has to open your app and tap through screens.The platform side lives in android.app.appfunctions and runs on Android 16 (API 36) and higher.How it worksThe system has four parts:You declare functions in Kotlin with annotations, and you describe them with KDoc.The KSP compiler generates a concrete service class and an XML file listing every function you declared.The OS indexes that XML file, so the system knows what your app can do.Callers discover and execute functions through AppFunctionManager.Agents decide when to call your function from its metadata: your KDoc descriptions plus app-level metadata. That makes the KDoc part of your API. An agent reads it to decide whether and how to call the function.Who can call your functionsCalling another app’s functions requires android.permission.EXECUTE_APP_FUNCTIONS. This is a privileged permission that Android grants only to authorized system assistants. An app can always call functions declared in its own package.So a random third-party app can’t call into your app. The callers are the system’s trusted assistants.SetupAdd the library and the KSP compiler:dependencies { implementation("androidx.appfunctions:appfunctions:1.0.0") // Use Kotlin Symbol Processing (KSP) for the appfunctions compiler plugin. ksp("androidx.appfunctions:appfunctions-compiler:1.0.0")}According to the setup guide, your project also needs:compileSdk 37 or higherAndroid Gradle Plugin 9.1.0 or higherThe KSP plugin configured in your top-level app moduleThe libraries target Java 11 bytecode, so you may need desugaring.Declaring a functionEverything starts from an abstract AppFunctionService marked with @AppFunctionServiceEntryPoint. All your annotated functions go inside it. Here is the task example from the official guide:@RequiresApi(36)@AndroidEntryPoint@AppFunctionServiceEntryPoint( serviceName = "TaskAppFunctionService", appFunctionXmlFileName = "task_app_function_service",)abstract class BaseTaskAppFunctionService : AppFunctionService() { @Inject internal lateinit var taskRepository: TaskRepository /** * Creates a task with a title, content, or both. * * @param createTaskParams The title and content of the task. At least one * of them is required. * @return The created task, including its ID. / @AppFunctionDeclaration(isDescribedByKDoc = true) suspend fun createTask( createTaskParams: CreateTaskParams, ): Task = withContext(Dispatchers.IO) { if (createTaskParams.title == null && createTaskParams.content == null) { throw AppFunctionInvalidArgumentException("A task needs a title, content, or both.") } val id = taskRepository.createTask( createTaskParams.title, createTaskParams.content ) return@withContext taskRepository .getTask(id) ?.toTask() ?: throw AppFunctionElementNotFoundException("Task not found for ID = $id") } private fun TaskEntity.toTask() = Task(id = id, title = title, content = description)}Parameter and return types use @AppFunctionSerializable:/* The title and content of a new task. /@AppFunctionSerializable(isDescribedByKDoc = true)data class CreateTaskParams( /* The title of the task. / val title: String?, /* The content of the task. / val content: String?,)/* The user-created task. /@AppFunctionSerializable(isDescribedByKDoc = true)data class Task( /* The ID of the task. / val id: String, /* The title of the task. / val title: String, /* The content of the task. */ val content: String,)Some details that are easy to miss:isDescribedByKDoc has no default. Since beta01 you must set it explicitly.Functions run on the UI thread by default. Make them suspend and switch to a dispatcher like Dispatchers.IO for any blocking work.Throw the typed exceptions. AppFunctionInvalidArgumentException, AppFunctionElementNotFoundException and their siblings tell the agent why a call failed. An uncaught exception reaches the agent as an AppFunctionAppUnknownException, which tells it almost nothing.Function IDs take the form "$enclosingClassName#$methodName". The compiler generates an ...Ids class, such as BaseTaskAppFunctionServiceIds.CREATE_TASK_ID, so you don’t hardcode strings.The manifestThe compiler generates the concrete TaskAppFunctionService and the XML schema, but you register the service yourself: The BIND_APP_FUNCTION_SERVICE permission means only the system can bind to the service.Turning functions on and off at runtimeNot every function should be on from day one, for example a feature behind a login or a paid tier. You can ship a function disabled:@AppFunctionDeclaration(isEnabled = false, isDescribedByKDoc = true)Then toggle it at runtime:AppFunctionManager.getInstance(context) ?.setAppFunctionEnabled( BaseTaskAppFunctionServiceIds.CREATE_TASK_ID, AppFunctionManager.APP_FUNCTION_STATE_ENABLED )getInstance returns null on devices that don’t support AppFunctions, so the safe call is required.TestingYou can check your functions from the command line before any agent is involved. List what your app exposes:adb shell cmd app_function list-app-functions --package $myPackageNameExecute a function with JSON parameters:adb shell "cmd app_function execute-app-function \ --package com.example.android.appfunctions \ --function 'com.example.android.appfunctions.BaseTaskAppFunctionService#createTask' \ --parameters '{"createTaskParams": {"title": "Buy milk", "content": "From grocery store"}}'"For automated tests, 1.0.0 ships androidx.appfunctions:appfunctions-testing with AppFunctionTestRule, which lets you write Robolectric tests for your AppFunction setup.The guide also lists inputs to test for, because a model generates the inputs and it won’t behave like a careful human:Omitted parameters arrive as null, 0, false or empty.Unexpected values such as blank strings, synonyms and out-of-range numbers.Thread behavior: confirm you aren’t blocking the main thread.Error paths: confirm you throw the right AppFunctionException subclass.Google also maintains an open-source AppFunctions testing agent at github.com/android/appfunctions.Getting into GeminiExposing functions on the device is one half. Having Gemini actually call them goes through Google’s Connected Apps Platform, currently a developer preview you apply to join. The flow:Create an “Android MCP” connected app in Google Connected Console and link your Play app to it. Each Play app can be linked to only one connected app.Upload an .aab that includes your AppFunctions.Provide at least three capabilities, three example prompts, a 512×512 icon, and policy and terms URLs.Add testers (@gmail.com accounts) running the exact matching version code.When your Play production release with AppFunctions is approved and rolled out, the connected app goes live automatically.One catch: Gemini Apps Developer Mode connects to MCP servers over HTTPS, so you can’t use it to test Android MCP connected apps. Use the Connected Console tester flow instead.What changed on the road to stableIf you tried an early alpha, a lot has been renamed. The big changes:alpha08 (Mar 2026): AppFunctionManagerCompat renamed to AppFunctionManager. The libraries now target Java 11.alpha10 (Jul 2026): Added @AppFunctionServiceEntryPoint and searchAppFunctions.alpha11 (Aug 2026): Added AppFunctionState.alpha12 (Sep 2026): Removed AppFunctionContext and AppFunctionConfiguration.alpha13 (Oct 2026): @AppFunction renamed to @AppFunctionDeclaration. Added AppFunctionAccessLevel.beta01 (Oct 2026): description renamed to instructions in app metadata. isDescribedByKDoc no longer has a default.rc01 (Nov 2026): Removed the legacy aggregateAppFunctions compiler option.1.0.0 (Nov 18, 2026): Stable.If you have alpha code, the annotation rename and the move to a service entry point are the migrations most likely to break your build.Things to keep in mindAndroid 16+ only. Plan a fallback for older devices. getInstance returning null is your signal.Callers are system assistants. Because of the privileged permission, your audience is assistants like Gemini, not arbitrary apps.Parts of the API are still experimental. Runtime registration (registerAppFunction, handleAppFunction) and AppFunctionSignature are marked @ExperimentalAppFunctionsApi, and the overview page still carries an experimental-preview notice. The core declare, index and execute path is what went stable.Gemini access is gated behind the Connected Apps developer preview.Where to startPick one action in your app that users repeat constantly, such as creating a note, logging a workout or checking an order. Write a clear KDoc for it, expose it as an AppFunction, and run it with adb. You’ll learn more from one working function than from reading the whole API reference.ResourcesAppFunctions overviewAdd AppFunctions to your appCreate and manage connected appsRelease notesAPI referenceSample and testing agentBuilding something with AppFunctions? Reply and tell us. We’d love to feature it in a future issue.AppFunctions 1.0 Is Stable: Turning Your Android App Into a Tool for AI Agents was originally published in ProAndroidDev on Medium, where people are continuing the conversation by highlighting and responding to this story.

Kaynak: Akshay Nandwana

#Android#Kotlin
Share

From other categories