Capacitor Android Build System
Relevant source files
The following files were used as context for generating this wiki page:
The Capacitor Android Build System enables KernelForge to operate as a standalone ARM64 Android application by wrapping a Next.js web application. It bridges web-based kernel development tools with the Android operating system, allowing users to compile, patch, and package kernels directly on mobile hardware.
This system integrates a statically exported Next.js 15 frontend into a Capacitor 6 native bridge. It automates the transition from web code to a signed arm64-v8a APK through a CI/CD pipeline, ensuring that features like AI log analysis and AnyKernel3 packaging are accessible as native mobile functions.
Sources: README.md:1-20, package.json:34-90
Architecture and Infrastructure
The build system utilizes a hybrid architecture where the UI and logic reside in a Next.js environment, while native capabilities are handled by Capacitor. The project targets modern Android devices, specifically optimizing for the SM8550 platform and ARM64 architecture.
Build Components
The following diagram illustrates the relationship between the web assets, the Capacitor bridge, and the final Android output.
This diagram shows the flow from static Next.js compilation to the final native Android package.
Sources: README.md:18-28, capacitor.config.ts:1-12
Dependency Configuration
The system relies on specific native and core dependencies to maintain the bridge and filesystem access.
| Dependency | Version | Purpose |
|---|---|---|
@capacitor/android | ^6.2.2 | Android platform support for Capacitor. |
@capacitor/core | ^6.1.0 | Core native bridge functionality. |
@capacitor/filesystem | ^6.0.4 | Native filesystem access for kernel exports. |
@capacitor/cli | ^8.3.0 | Command line tools for syncing and building. |
Sources: package.json:34-37, package.json:86
Build Lifecycle and Orchestration
The build system follows a structured lifecycle to convert web components into a flashable Android application. This process is managed through npm scripts and automated GitHub Actions.
Build Workflow
The following sequence diagram detail the steps taken during a standard build and sync operation.
This diagram describes the synchronization between the web export and the native Android project.
Sources: package.json:11-15, README.md:30-40
Automated CI/CD Pipeline
GitHub Actions automates the production of releases whenever a new version tag is pushed. The pipeline executes four primary steps:
- Compiles the Next.js static payload.
- Injects the payload into the Android Capacitor wrapper.
- Builds, aligns, and signs the
arm64-v8aAPK. - Publishes the APK to the repository's Releases page.
Sources: README.md:33-40
Configuration and Environment
The system configuration is defined in capacitor.config.ts, which sets the identity and behavior of the Android application.
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'com.kcrafter.app',
appName: 'Lineage Kernelcrafter',
webDir: 'out',
bundledWebRuntime: false,
server: {
androidScheme: 'https'
}
};
Sources: capacitor.config.ts:1-12
Configuration Parameters
| Parameter | Value | Description |
|---|---|---|
appId | com.kcrafter.app | The unique package identifier for Android. |
webDir | out | The directory containing statically exported Next.js files. |
androidScheme | https | The scheme used by the internal Capacitor server. |
themeColor | #00ff55 | The primary theme color for the mobile viewport. |
Sources: capacitor.config.ts:4-10, src/app/layout.tsx:19
Native Integration Logic
The application logic within src/app/page.tsx interacts with the build system to manage kernel assets. When a build completes, the system prepares images and ZIP packages for the local filesystem.
Build and Package Flow
- Compilation: The system executes kernel compilation (simulated via
startBuild) and tracks progress through state. - Image Preparation: Upon completion (100% progress), it generates a
Blobrepresenting theImage.lz4-dtbfile. - AnyKernel3 Packaging: The system bundles the image into a flashable ZIP structure.
- Native Transfer: The web-based download triggers are caught by the Capacitor bridge to save files to the device storage.
Sources: src/app/page.tsx:75-163
Summary
The Capacitor Android Build System provides a robust bridge between high-level Next.js kernel management tools and the Android native environment. By utilizing a static export strategy and an automated CI/CD pipeline, the system ensures consistent delivery of ARM64 APKs optimized for specialized development tasks on the SM8550 platform.