apkbuild

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package apkbuild provides functionality for building signed Android APKs from Go packages using the Android SDK/NDK toolchain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(cfg Config) error

Build produces a signed APK from a Go package.

The pipeline mirrors what the Makefile does:

  1. Cross-compile Go → .so (go build -buildmode=c-shared)
  2. Package with aapt (aapt package -f -M manifest -I platform.jar -F base.apk)
  3. Add native libs (cd buildDir && zip -r base.apk lib/)
  4. Align (zipalign -f -p 4)
  5. Sign (apksigner sign --ks keystore)

Types

type Config

type Config struct {
	// GoPackage is the Go package to build (e.g., "./examples/camera/display").
	GoPackage string

	// OutputPath is the output APK file path.
	OutputPath string

	// ManifestPath is the path to AndroidManifest.xml.
	ManifestPath string

	// Architectures to build for (e.g., ["arm64", "x86_64"]).
	Architectures []string

	// APILevel is the Android API level (e.g., 35).
	APILevel int

	// KeystorePath is the path to the signing keystore.
	KeystorePath string

	// KeystorePass is the keystore password.
	KeystorePass string

	// LibName is the name for the shared library (without lib prefix and .so suffix).
	LibName string

	// AndroidHome is the path to the Android SDK (default: $ANDROID_HOME or ~/Android/Sdk).
	AndroidHome string

	// NDKPath is the path to the Android NDK (default: latest in AndroidHome/ndk/).
	NDKPath string
}

Config holds the configuration for building an APK.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL