Get started¶
For the experimental browser target, use the WebAssembly preview guide. The setup below applies to the published JVM libraries.
Add ByteInk to your project¶
ByteInk is published to GitHub Packages. The current release is 0.2.1. Use Java 25+, Kotlin 2.4.20 and Compose Multiplatform 1.12.1 for the tested setup. The natives for Linux and Windows, on x86_64 and arm64, ship inside the dependency; the loader picks the one matching the JVM's os.name and os.arch.
1. Add a GitHub token¶
GitHub's Maven registry requires authentication, including for public packages. Create a classic personal access token with read:packages and add it to ~/.gradle/gradle.properties, outside source control:
In CI, the GITHUB_ACTOR and GITHUB_TOKEN environment variables are used instead. Registry documentation.
2. Add the repository¶
In the consuming project's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google() // androidx.ink comes from Google's Maven
mavenCentral() // Kotlin, Compose
maven("https://maven.pkg.github.com/crownbyte0b/byteink") {
content { includeGroup("com.vivenotes.byteink") }
credentials {
username = providers.gradleProperty("gpr.user").orElse(providers.environmentVariable("GITHUB_ACTOR")).orNull
password = providers.gradleProperty("gpr.key").orElse(providers.environmentVariable("GITHUB_TOKEN")).orNull
}
}
}
}
3. Add the dependencies¶
In the consumer's JVM dependencies:
kotlin {
jvm()
sourceSets.jvmMain.dependencies {
implementation("com.vivenotes.byteink:byteink-compose:0.2.1")
implementation("com.vivenotes.byteink:byteink-kit:0.2.1")
implementation(compose.desktop.currentOs)
}
}
compose.desktop {
application {
mainClass = "your.package.MainKt"
jvmArgs += "--enable-native-access=ALL-UNNAMED"
}
}
Apply the Kotlin Compose compiler and Compose Multiplatform plugins in your application. The application supplies its OS- and CPU-specific Compose/Skiko runtime: compose.desktop.currentOs selects it for the build machine, and a build that names one explicitly needs the matching desktop-jvm-<linux|windows>-<x64|arm64> artifact. byteink-compose and byteink-kit bring in core, the pinned AndroidX modules and the native loader. Add com.vivenotes.byteink:byteink-testing:0.2.1 only if you need notebook utilities.
For a plain JVM project, put the same dependencies in dependencies { ... }. The example build uses a standalone JVM consumer.
Avoid adding Google's androidx.ink:ink-nativeloader or ink-nativeloader-jvm separately: they conflict with ByteInk's loader. See troubleshooting.
Create, store and rebuild a stroke¶
This uses the same input/brush types as AndroidX Ink. elapsedTimeMillis starts at zero for each stroke.
package wiki
import androidx.ink.brush.InputToolType
import androidx.ink.strokes.MutableStrokeInputBatch
import androidx.ink.strokes.Stroke
import com.vivenotes.byteink.core.InkRuntime
import com.vivenotes.byteink.kit.AuthoredViveStroke
import com.vivenotes.byteink.kit.ViveBrushes
import com.vivenotes.byteink.kit.ViveInkTool
fun firstStroke(): AuthoredViveStroke {
InkRuntime.load()
val tool = ViveInkTool(
familyId = ViveBrushes.MARKER,
sizeDp = 6f,
colorArgb = 0xff202020.toInt(),
colorFollowsTheme = false,
)
val inputs = MutableStrokeInputBatch().apply {
add(type = InputToolType.MOUSE, x = 10f, y = 50f, elapsedTimeMillis = 0L)
add(type = InputToolType.MOUSE, x = 90f, y = 50f, elapsedTimeMillis = 80L)
}
return tool.complete(
stroke = Stroke(tool.brush, inputs),
id = "stroke-1",
pageId = "page-1",
seq = 1,
createdAt = 42L,
)
}
ViveInkTool.complete returns the finished stroke and a new stored row. canonicalStroke rebuilds that row through the codec, giving the geometry a reload will use. Persist row with a unique ID, correct page ID, and repository-allocated seq.
For live drawing, continue to the Compose surface or native low-latency surfaces. All tool parameters.
Native Wayland setup¶
The native Wayland authoring backend is tested with JBR 25, a live Wayland compositor and these application JVM arguments:
jvmArgs += listOf(
"-Dawt.toolkit.name=WLToolkit",
"--add-opens=java.desktop/sun.awt.wl=ALL-UNNAMED",
"--enable-native-access=ALL-UNNAMED",
)
Use the SwingGraphics Compose host or direct Swing panel shown in the native authoring example. An ordinary Java 25 Linux runtime can use X11/XWayland on a Wayland desktop; WAYLAND_DISPLAY alone does not select JBR's Wayland toolkit. Windows and X11 native authoring need Java 25+ and native access, without the JBR-specific flags.
Other repository choices¶
To build against a ByteInk checkout instead of a published release, use version 0.2.1-SNAPSHOT in the dependencies above.
| Mode | Setup |
|---|---|
| Local build repository | Publish the checkout as shown below and add the repository. |
| Source/composite | Add includeBuild("../byteink") to settings; keep the normal dependency declarations. Native outputs are still required. |
| Maven local | Run ./gradlew publishToMavenLocal in ByteInk; configure mavenLocal { content { includeGroup("com.vivenotes.byteink") } }. |
For a local build repository, publish the checkout once; its native build outputs must be present:
# In ByteInk; omit the native builds when their pinned outputs already exist.
native/build-linux.sh
native/build-windows.sh
./gradlew publishAllPublicationsToBuildRepository
Then add it to the consumer's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
maven {
url = uri("../byteink/build/repo")
content { includeGroup("com.vivenotes.byteink") }
}
google()
mavenCentral()
}
}
Maintainers can publish a version from a tag or a manual CI run.