Ink App Builder 标志

Ink App Builder

组织热门
android
ink-app-builder

使用 Jetpack Ink(androidx.ink)和 Compose,为 Android 应用添加墨迹书写和徒手绘图功能。实现触控笔或触摸绘图界面、渲染湿墨迹和干墨迹、配置内置画笔(压力笔、记号笔、荧光笔)、实现基于几何形状的擦除、线性撤销和重做历史记录,或使用 Room 持久化笔迹时,可使用此技能。提供可运行的 Compose 和 ViewModel 实现。不要用于基于 View(XML)的墨迹书写或以编程方式创建自定义 BrushFamily。需要创建自定义 BrushFamily、自定义笔尖形状或行为节点图时,建议使用 ink-custom-brush-builder 技能。

Add to TypingMind

概览

发布者android
代码仓库skills
技能名称ink-app-builder
星标数
10K
复刻数
654
附带文件
8
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 8 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 android 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Ink App Builder AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/android/skills/tree/main/jetpack-compose/ink/ink-app-builder
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/android/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/jetpack-compose/ink/ink-app-builder .claude/skills/ink-app-builder
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Ink App Builder,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Ink App Builder。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Ink App Builder 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

The Android Ink API (androidx.ink) is a modular Jetpack library for building high-performance, low-latency freehand drawing experiences on Android. It uses a wet ink and dry ink two-phase model:

  • Wet ink : Real-time, ultra-low-latency rendering while the user is drawing, handled by the InProgressStrokes composable.
  • Dry ink : Finalized, immutable Stroke objects rendered by the app using CanvasStrokeRenderer.

Setup and dependencies

The Ink API requires minSdk = 26 , which corresponds to Android 8.0 (API level 26) and higher. All androidx.ink modules MUST share an identical version in gradle/libs.versions.toml. Ask user permission before modifying project build files.

Version selection (1.0.0 stable versus 1.1.0-alpha03 and higher)

  • Use 1.0.0 (Stable) for production apps that rely on StockBrushes or pre-serialized .brush assets decoded with BrushFamily.decode. In 1.0.0 stable, BrushFamily.encode, BrushFamily.decode, AndroidBrushFamilySerialization, and BrushFamilyDecodeCallback require @OptIn(ExperimentalInkCustomBrushApi::class).
  • Use 1.1.0-alpha03 and higher when the app constructs programmatic custom brushes (BrushFamily, BrushCoat, BrushTip, BrushPaint, BrushBehavior) in Kotlin code. Starting in 1.1.0-alpha02 and higher, BrushFamily serialization requires no @OptIn (and in 1.1.0-alpha05 and higher, ExperimentalInkCustomBrushApi is @RestrictTo(LIBRARY_GROUP), so NEVER annotate 1.1.0-alpha03 and higher code with it).

Version catalog (gradle/libs.versions.toml)

[versions]
ink = "<latest_version>"
inputMotionPrediction = "<latest_version>"

[libraries]
# Core Ink modules
androidx-ink-authoring         = { module = "androidx.ink:ink-authoring",         version.ref = "ink" }
androidx-ink-brush             = { module = "androidx.ink:ink-brush",             version.ref = "ink" }
androidx-ink-geometry          = { module = "androidx.ink:ink-geometry",          version.ref = "ink" }
androidx-ink-nativeloader      = { module = "androidx.ink:ink-nativeloader",      version.ref = "ink" }
androidx-ink-rendering         = { module = "androidx.ink:ink-rendering",         version.ref = "ink" }
androidx-ink-strokes           = { module = "androidx.ink:ink-strokes",           version.ref = "ink" }
androidx-ink-storage           = { module = "androidx.ink:ink-storage",           version.ref = "ink" }

# Compose integration modules
androidx-ink-authoring-android = { module = "androidx.ink:ink-authoring-android", version.ref = "ink" }
androidx-ink-authoring-compose = { module = "androidx.ink:ink-authoring-compose", version.ref = "ink" }
androidx-ink-brush-compose     = { module = "androidx.ink:ink-brush-compose",     version.ref = "ink" }
androidx-ink-geometry-compose  = { module = "androidx.ink:ink-geometry-compose",  version.ref = "ink" }

# Motion prediction (required for low-latency stylus tracking)
androidx-input-motionprediction = { module = "androidx.input:input-motionprediction", version.ref = "inputMotionPrediction" }

# Persistence (kotlinx.serialization + Room with KSP)
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
androidx-room-runtime      = { module = "androidx.room:room-runtime",  version.ref = "room" }
androidx-room-ktx          = { module = "androidx.room:room-ktx",      version.ref = "room" }
androidx-room-compiler     = { module = "androidx.room:room-compiler", version.ref = "room" }

[plugins]
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp                  = { id = "com.google.devtools.ksp",                   version.ref = "ksp" }

App module configuration (app/build.gradle.kts)

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.kotlin.serialization)
    alias(libs.plugins.ksp) // Mandatory when using Room in Kotlin
}

android {
    defaultConfig {
        minSdk = 26
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    buildFeatures {
        compose = true
    }
}

dependencies {
    implementation(libs.androidx.ink.authoring)
    implementation(libs.androidx.ink.brush)
    implementation(libs.androidx.ink.geometry)
    implementation(libs.androidx.ink.nativeloader)
    implementation(libs.androidx.ink.rendering)
    implementation(libs.androidx.ink.strokes)
    implementation(libs.androidx.ink.storage)

    implementation(libs.androidx.ink.authoring.android)
    implementation(libs.androidx.ink.authoring.compose)
    implementation(libs.androidx.ink.brush.compose)
    implementation(libs.androidx.ink.geometry.compose)

    implementation(libs.androidx.input.motionprediction)

    implementation(libs.kotlinx.serialization.json)
    implementation(libs.androidx.room.runtime)
    implementation(libs.androidx.room.ktx)
    ksp(libs.androidx.room.compiler) // NEVER use annotationProcessor in Kotlin
}

Core drawing surface and default brush

Create a standard pressure-sensitive pen Brush with Brush.createWithComposeColor (from ink-brush-compose). The epsilon parameter defines the minimum distance between two input points, in stroke-space units, to be considered visually distinct (0.1f for general drawing, 0.01f for fine precision tools; Brush enforces 0f < epsilon <= size):

kotlin
/**
 * Creates a default pressure-sensitive pen [Brush].
 *
 * The `epsilon` parameter sets the geometric tolerance (minimum point distance
 * in stroke units) controlling how far a stroke can be zoomed before triangle
 * artifacts appear (`0f < epsilon <= size`).
 */
fun createDefaultPenBrush(): Brush {
    return Brush.createWithComposeColor(
        family = StockBrushes.pressurePen(),
        color = Color.Black,
        size = 5f,
        epsilon = 0.1f,
    )
}

Stack two layers inside a Box for the drawing surface: a Compose Canvas that renders finalized dry Stroke objects inside nativeCanvas.withSave using CanvasStrokeRenderer, and an InProgressStrokes composable on top for low-latency wet ink capture. Encapsulate a synchronous pendingStrokes Compose Snapshot State buffer inside DrawingSurface so the dry Canvas invalidates in the exact same UI thread run loop when onStrokesFinished fires, preventing a 1-frame wet-to-dry flicker:

kotlin
@Composable
fun DrawingSurface(
    strokes: List<Stroke>,
    canvasStrokeRenderer: CanvasStrokeRenderer,
    currentBrush: Brush,
    onGetNextBrush: () -> Brush,
    onStrokesFinished: (List<Stroke>) -> Unit,
    isEraserMode: Boolean,
    modifier: Modifier = Modifier,
    textureStore: AppTextureBitmapStore = LocalTextureStore.current,
    onErase: (Float, Float) -> Unit = { _, _ -> },
    onEraseStart: () -> Unit = {},
    onEraseEnd: () -> Unit = {},
) {
    val cacheGen by textureStore.generation.collectAsStateWithLifecycle()

    // Holds newly finished strokes synchronously for the single frame before
    // asynchronous StateFlow collection delivers the updated strokes list.
    var pendingStrokes by remember { mutableStateOf<List<Stroke>>(emptyList()) }

    SideEffect {
        if (pendingStrokes.isNotEmpty()) {
            pendingStrokes = if (strokes.isEmpty()) {
                emptyList()
            } else {
                pendingStrokes.filter { pending -> strokes.none { it === pending } }
            }
        }
    }

    val strokesToDraw = remember(strokes, pendingStrokes) {
        if (pendingStrokes.isEmpty()) {
            strokes
        } else {
            strokes + pendingStrokes.filter { pending -> strokes.none { it === pending } }
        }
    }
    val identityMatrix = remember { Matrix() }

    val currentOnErase by rememberUpdatedState(onErase)
    val currentOnEraseStart by rememberUpdatedState(onEraseStart)
    val currentOnEraseEnd by rememberUpdatedState(onEraseEnd)

    Box(modifier = modifier) {
        // Layer 1: Dry ink - completed strokes + same-frame pending handoff strokes
        Canvas(modifier = Modifier.fillMaxSize()) {
            val nativeCanvas = drawContext.canvas.nativeCanvas
            strokesToDraw.fastForEach { stroke ->
                nativeCanvas.withSave {
                    canvasStrokeRenderer.draw(
                        canvas = this,
                        stroke = stroke,
                        strokeToScreenTransform = identityMatrix,
                    )
                }
            }
        }

        // Layer 2: Eraser touch handler OR Wet ink (InProgressStrokes)
        if (isEraserMode) {
            Box(
                modifier = Modifier
                    .fillMaxSize()
                    .pointerInput(Unit) {
                        detectDragGestures(
                            onDragStart = { currentOnEraseStart() },
                            onDragEnd = { currentOnEraseEnd() },
                            onDragCancel = { currentOnEraseEnd() },
                            onDrag = { change, _ ->
                                currentOnErase(change.position.x, change.position.y)
                                change.consume()
                            },
                        )
                    }
            )
        } else {
            key(cacheGen) {
                InProgressStrokes(
                    defaultBrush = currentBrush,
                    nextBrush = onGetNextBrush,
                    onStrokesFinished = { newStrokes ->
                        pendingStrokes = pendingStrokes + newStrokes
                        onStrokesFinished(newStrokes)
                    },
                    textureBitmapStore = textureStore,
                )
            }
        }
    }
}

Workflow and task routing

Follow these conditional instructions based on the requested task:

  • Step 1 (Dependencies and SDK setup) : When adding Ink API dependencies or configuring minSdk, follow the setup blocks in this file and the Ink API setup guide. Verify that ink-nativeloader, ink-authoring-android, and androidx.input:input-motionprediction are present.
  • Step 2 (Drawing surface and stroke rendering) : When creating a Compose drawing screen with wet ink (InProgressStrokes) and dry ink (CanvasStrokeRenderer), implement DrawingSurface from this file and review Draw a stroke. For InProgressStrokes parameter details, BlendMode.Multiply highlighter layer compositing, and TextureBitmapStore generation invalidation, you MUST follow drawing-and-brushes.md.
  • Step 3 (Stock brushes and brush switching) : When creating, modifying, or switching stock brushes (StockBrushes.pressurePen, marker, highlighter, dashedLine, or emojiHighlighter), review Brush APIs and you MUST follow drawing-and-brushes.md for epsilon geometry constraints, highlighter alpha preservation, and Android 14 (API level 34) emojiHighlighter rules.
  • Step 4 (Eraser, undo and redo, and MVVM architecture) : When implementing a geometry-based stroke eraser, linear undo and redo history stacks, or MVVM ViewModel and Hilt wiring, review Geometry APIs and you MUST follow editing-and-architecture.md.
  • Step 5 (Persistence, bitmap export, and gesture coexistence) : When saving and loading strokes with Room (StrokeInputBatch.encode and decode), preserving UI state across configuration changes, exporting drawings to a Bitmap or PNG file, or combining long-press drag gestures with drawing (pointerInputWithSiblingFallthrough), review State preservation and persistent storage and you MUST follow persistence-and-advanced.md.
  • Programmatic custom brushes : For custom BrushFamily creation, custom tip shapes, or behavior node graphs, suggest the ink-custom-brush-builder skill.

Antipatterns

  • NEVER use InProgressStrokesView in Compose screens ---that's the View-based API. Use the InProgressStrokes composable instead.
  • NEVER omit ink-nativeloader or ink-authoring-android ---missing ink-nativeloader throws UnsatisfiedLinkError, and missing ink-authoring-android throws ClassNotFoundException at runtime.
  • NEVER use View.OnTouchListener or MotionEvent directly ---the InProgressStrokes composable captures and processes touch and stylus input internally.
  • NEVER draw strokes manually with Canvas.drawPath or by iterating stroke points---always call CanvasStrokeRenderer.draw(canvas, stroke, transform).
  • NEVER call CanvasStrokeRenderer.create(forcePathRendering = true) ---the 2-argument forcePathRendering overload is @RestrictTo(LIBRARY_GROUP). Use the public CanvasStrokeRenderer.create(textureStore) factory, which automatically detects software Bitmap canvases and falls back to path rendering.
  • NEVER rely solely on asynchronous StateFlow collection in onStrokesFinished ---InProgressStrokes removes completed wet strokes immediately after onStrokesFinished returns on the UI thread, while collectAsStateWithLifecycle updates on a later run loop, causing a 1-frame wet-to-dry flicker. Always mutate Compose Snapshot State synchronously in the same UI thread run loop using a pendingStrokes buffer as shown in DrawingSurface.
  • NEVER store strokes as bitmaps for undo, redo, or database persistence---store Stroke objects in memory and serialize StrokeInputBatch bytes with brush metadata for disk storage.
  • NEVER use annotationProcessor for Room in Kotlin ---always apply the com.google.devtools.ksp plugin and use ksp(libs.androidx.room.compiler) to avoid AppDatabase_Impl does not exist crashes at launch.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Ink App Builder AI 技能有什么作用?

使用 Jetpack Ink(androidx.ink)和 Compose,为 Android 应用添加墨迹书写和徒手绘图功能。实现触控笔或触摸绘图界面、渲染湿墨迹和干墨迹、配置内置画笔(压力笔、记号笔、荧光笔)、实现基于几何形状的擦除、线性撤销和重做历史记录,或使用 Room 持久化笔迹时,可使用此技能。提供可运行的 Compose 和 ViewModel 实现。不要用于基于 View(XML)的墨迹书写或以编程方式创建自定义 BrushFamily。需要创建自定义 BrushFamily、自定义笔尖形状或行为节点图时,建议使用 ink-custom-brush-builder 技能。

为什么在 TypingMind 中使用 Ink App Builder?

因为您只需安装一次,就能搭配任何模型使用。Ink App Builder 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Ink App Builder?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/android/skills/tree/main/jetpack-compose/ink/ink-app-builder。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Ink App Builder?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Ink App Builder 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Ink App Builder 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Ink App Builder AI 技能免费吗?

是的。android 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇