Skip to content
skotch
...

JVM Targets

Skotch can produce JVM class files, packaged JARs, DEX bytecode, and unsigned APKs. This guide covers project-level builds for each.

myapp/
build.gradle.kts
src/main/kotlin/
Main.kt
Utils.kt
plugins {
kotlin("jvm")
application
}
group = "com.example"
version = "1.0.0"
application {
mainClass.set("MainKt")
}
Terminal window
cd myapp
skotch build
java -jar build/example.jar

The JAR includes a META-INF/MANIFEST.MF with the Main-Class header, so java -jar works directly.

For projects with library modules:

myapp/
settings.gradle.kts
app/
build.gradle.kts
src/main/kotlin/Main.kt
lib/
build.gradle.kts
src/main/kotlin/Helper.kt

settings.gradle.kts:

rootProject.name = "myapp"
include(":app", ":lib")

app/build.gradle.kts:

plugins {
kotlin("jvm")
application
}
dependencies {
implementation(project(":lib"))
}
application {
mainClass.set("MainKt")
}

Skotch compiles :lib first, then :app, and merges all class files into the final JAR.

Terminal window
skotch build -C myapp

myapp/
build.gradle.kts
src/main/kotlin/
MainActivity.kt
plugins {
id("com.android.application")
kotlin("android")
}
android {
namespace = "com.example.myapp"
compileSdk = 34
defaultConfig {
applicationId = "com.example.myapp"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
}
}
build/app-unsigned.apk
skotch build

The APK contains:

  • AndroidManifest.xml — binary AXML generated from the build config
  • classes.dex — DEX bytecode compiled from your Kotlin sources
  • resources.arsc — included if present (optional)

If your build.gradle.kts uses JVM plugins but you want to produce an APK:

Terminal window
skotch build --target android

For quick experiments, skotch emit compiles one file at a time without needing a project structure:

Terminal window
# JVM class file
skotch emit --target jvm hello.kt -o HelloKt.class
java -cp . HelloKt
# DEX file
skotch emit --target dex hello.kt -o classes.dex
# Native binary (requires clang)
skotch emit --target native hello.kt -o hello
./hello
# LLVM IR (text)
skotch emit --target llvm hello.kt -o hello.ll
# Kotlin library archive
skotch emit --target klib hello.kt -o hello.klib

Skotch supports APK Signature Scheme v2 signing with PEM key files:

android {
signingConfigs {
debug {
storeFile = "keys/debug.pem"
storePassword = ""
keyAlias = "debug"
keyPassword = ""
}
}
}