A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): Package Project → Android hands back a signed APK
esengineabca675244df
diff --git a/build-tools/cli.js b/build-tools/cli.jsindex efca65e7f..ecd310f9d 100644--- a/build-tools/cli.js+++ b/build-tools/cli.js@@ -168,9 +168,11 @@ program.option('--platform <platform>', 'Android platform', 'android-33').option('--ios-min <version>', 'iOS deployment target', '17.0').option('--simulator', 'iOS: build the simulator slice (needs a simulator Dawn)', false)- .option('--package', 'Assemble the app around --content: Android a signed APK, iOS a self-contained Xcode project', false)- .option('--keystore <path>', 'Android --package: signing keystore (default: the debug one)')- .option('--jdk <dir>', 'JDK home for the APK step (else JAVA_HOME, or the JDK Android Studio bundles)')+ .option('--package', 'Assemble the app around --content from the installed runtime template: Android a signed APK, iOS an Xcode project', false)+ .option('--key <pem>', 'Android --package: PEM private key to sign with (default: the development key)')+ .option('--cert <pem>', 'Android --package: PEM certificate for --key')+ .option('--passphrase <text>', 'Passphrase for an encrypted --key')+ .option('--jdk <dir>', 'JDK home for building a template (javac + d8), else JAVA_HOME or Android Studio\'s').option('--content <dir>', 'Ship an exported project (Package Project -> Android / iOS) as the app content').option('--no-template', 'Skip refreshing this machine\'s runtime template with the build').option('--template-only', 'Emit the runtime template from an existing build, without rebuilding', false)@@ -192,7 +194,9 @@ programiosMin: options.iosMin,simulator: options.simulator,package: options.package,- keystore: options.keystore,+ key: options.key,+ cert: options.cert,+ passphrase: options.passphrase,jdk: options.jdk,content: options.content,});diff --git a/build-tools/tasks/native.js b/build-tools/tasks/native.jsindex 4ac87ff06..8717f2afd 100644--- a/build-tools/tasks/native.js+++ b/build-tools/tasks/native.js@@ -15,13 +15,14 @@ import config from '../build.config.js';import * as logger from '../utils/logger.js';import { runCommand, getCpuCount, resolvePython } from '../utils/emscripten.js';import { requireSdk, requireNdk, sdkCmake } from '../utils/android.js';-import { packageNativeApk } from './nativePackage.js';import { emitNativeTemplate, readEngineVersion } from './nativeTemplateEmit.js';import {- BYTECODE_FILE, findTemplate, iosTemplateSources, templateStoreDir,+ BYTECODE_FILE, DEFAULT_ABI, findTemplate, iosTemplateSources, templateStoreDir,} from '../utils/nativeTemplate.js';import { readAppConfig, fillTemplate } from '../utils/nativeApp.js';import { emitIosXcodeProject } from '../utils/iosProject.js';+import { assembleApk, apkFileName } from '../utils/apk.js';+import { debugSigningKey, signingKeyFromPem } from '../utils/androidKeystore.js';// Generate the native (QuickJS) ECS bindings from the SAME reflection source EHT// uses for the web embind bindings — so the two surfaces can never drift. Written@@ -303,12 +304,6 @@ async function buildAndroidHost(options) {});}- if (options.package) {- await packageNativeApk({- dawnBuild, abi, platform, keystore: options.keystore, jdk: options.jdk,- content: options.content,- });- }}// Xcode ships the iPhoneOS SDK; the Command Line Tools alone do not. Point the@@ -468,29 +463,63 @@ async function buildIosHost(options) {logger.info('Next: cd native/ios && xcodegen && open EstellaiOS.xcodeproj — pick your Team, then Run.');}-/**- * Wrap an iOS export in an Xcode project — from the installed runtime template,- * with no compiler involved. The same call the editor's export makes, so a project- * assembled here and one assembled there are the same project.- */-async function packageIosProject(options) {+/** The export to package, resolved and checked. */+function packagedContent(options) {const rootDir = config.paths.root;if (!options.content) {throw new Error('--package needs the game to package: pass --content <dir> from '- + "the editor's iOS export.");+ + "the editor's export.");}- const contentDir = path.isAbsolute(options.content)- ? options.content : path.join(rootDir, options.content);- if (!existsSync(contentDir)) throw new Error(`--content dir not found: ${contentDir}`);+ const dir = path.isAbsolute(options.content) ? options.content : path.join(rootDir, options.content);+ if (!existsSync(dir)) throw new Error(`--content dir not found: ${dir}`);+ return dir;+}- const engineVersion = readEngineVersion(rootDir);- const template = findTemplate({ platform: 'ios', engineVersion });+/** The installed runtime template for @p platform, or a message naming how to get one. */+function requireTemplate(platform, abi) {+ const engineVersion = readEngineVersion(config.paths.root);+ const template = findTemplate({ platform, engineVersion, abi });if (!template || template.missing.length > 0) {- throw new Error(`No iOS runtime template for v${engineVersion}. Build one with `- + '`cli native --target ios`, or install a release archive into '+ throw new Error(`No ${platform} runtime template for v${engineVersion}. Build one with `+ + `\`cli native --target ${platform}\`, or install a release archive into `+ `${templateStoreDir()}.`);}+ return template;+}++/**+ * Assemble a signed APK around an export — from the installed runtime template,+ * with no Android SDK involved. The same call the editor's export makes.+ */+async function packageAndroidApk(options) {+ const abi = options.abi || DEFAULT_ABI.android;+ const template = requireTemplate('android', abi);+ const contentDir = packagedContent(options);+ const app = readAppConfig(contentDir, (m) => logger.warn(m));++ const key = options.key+ ? signingKeyFromPem({ key: options.key, cert: options.cert, passphrase: options.passphrase })+ : debugSigningKey();+ if (!options.key) logger.info('Signing with the development key (sideload only — not for a store).');++ logger.step('Assembling the APK...');+ const apk = assembleApk({ templateDir: template.dir, contentDir, app, abi, key });+ const out = path.join(contentDir, apkFileName(app.id));+ writeFileSync(out, apk);++ logger.success(`APK: ${out} (${(apk.length / 1048576).toFixed(1)} MB)`);+ logger.info(`App: ${app.name} (${app.id}) v${app.version} — ${app.orientation}, signed by ${key.name}`);+ logger.info(`Install it with: adb install -r ${out}`);+}+/**+ * Wrap an iOS export in an Xcode project — from the installed runtime template,+ * with no compiler involved. The same call the editor's export makes, so a project+ * assembled here and one assembled there are the same project.+ */+async function packageIosProject(options) {+ const template = requireTemplate('ios');+ const contentDir = packagedContent(options);const app = readAppConfig(contentDir, (m) => logger.warn(m));const projectDir = await emitIosXcodeProject(contentDir, app, iosTemplateSources(template.dir),@@ -525,9 +554,8 @@ export async function buildNative(options = {}) {throw new Error(`Unknown --target ${target} (expected android or ios).`);}if (options.templateOnly) return emitFromExistingBuild(target, options);- // On iOS, packaging is ASSEMBLY: the pieces come from the installed runtime- // template, so it needs no toolchain and never builds. (Android's assembler- // still reads the build tree — see docs/REARCH_NATIVE_DISTRIBUTION.md P1.)- if (options.package && target === 'ios') return packageIosProject(options);+ // Packaging is ASSEMBLY: every piece comes from the installed runtime template,+ // so it needs no toolchain and never builds.+ if (options.package) return target === 'ios' ? packageIosProject(options) : packageAndroidApk(options);return target === 'ios' ? buildIosHost(options) : buildAndroidHost(options);}diff --git a/build-tools/tasks/nativePackage.js b/build-tools/tasks/nativePackage.jsdeleted file mode 100644index 2b4ea5561..000000000--- a/build-tools/tasks/nativePackage.js+++ /dev/null@@ -1,174 +0,0 @@-// SPDX-License-Identifier: Apache-2.0-// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-//-// APK packaging for the native host — the Android counterpart of what Xcode does-// for native/ios. No gradle: the host is a NativeActivity with no Java, so the-// APK is just aapt2 link, the .so payload, zipalign and apksigner. The game and-// its content go in as assets/, which is where the host's readAsset() looks.--import path from 'path';-import { existsSync, readFileSync } from 'fs';-import { mkdir, copyFile, cp, rm, writeFile } from 'fs/promises';-import config from '../build.config.js';-import * as logger from '../utils/logger.js';-import { runCommand } from '../utils/emscripten.js';-import { requireSdk, requireNdk, buildTool, platformJar, ndkTool, ndkLibcxxShared, javaHome, jdkTool } from '../utils/android.js';-import { readAppConfig, androidScreenOrientation, fillTemplate } from '../utils/nativeApp.js';-import { BYTECODE_FILE } from '../utils/nativeTemplate.js';-import { compileJavaShim } from './nativeTemplateEmit.js';---const HOST_LIBRARY = 'libestella_js_host.so';--const MANIFEST_TEMPLATE = path.join('native', 'android', 'host', 'AndroidManifest.xml.in');--/** The APK is named after the app it contains, so packaging a second project does- * not quietly replace the first one's file. */-const apkName = (appId) => `${appId.split('.').pop() || 'estella'}.apk`;--// A debug keystore is enough to sideload; Android Studio uses the same one. Create-// it on first use so packaging never stops to ask for credentials.-async function debugKeystore(jdk) {- const home = process.env.HOME || process.env.USERPROFILE || '';- const keystore = path.join(home, '.android', 'debug.keystore');- if (existsSync(keystore)) return keystore;- logger.step('Creating the Android debug keystore...');- await mkdir(path.dirname(keystore), { recursive: true });- await runCommand(jdkTool('keytool', jdk), [- '-genkeypair', '-keystore', keystore, '-storepass', 'android', '-keypass', 'android',- '-alias', 'androiddebugkey', '-keyalg', 'RSA', '-keysize', '2048', '-validity', '10000',- '-dname', 'CN=Android Debug,O=Android,C=US',- ]);- return keystore;-}--// APKs are zips; `jar` ships with the JDK that apksigner already requires, so it-// is the one archiver we can count on wherever packaging runs.-//-// It carries the ASSETS too, rather than letting `aapt2 link -A` do it: on Windows-// aapt2 writes nested asset paths with backslashes ("assets/assets\scenes\x"), and-// a zip entry name must use forward slashes — so AAssetManager could not open-// anything in a subdirectory. Invisible while the packaged content was a handful-// of flat files; every real project export has directories.-async function addToApk(apk, stagingDir, entries, jdk) {- await runCommand(jdkTool('jar', jdk), ['ufM', apk, ...entries.flatMap((e) => ['-C', stagingDir, e])]);-}--export async function packageNativeApk(options = {}) {- const rootDir = config.paths.root;- const buildDir = path.join(rootDir, 'build-native');- const library = path.join(buildDir, HOST_LIBRARY);- if (!existsSync(library)) {- throw new Error(`${HOST_LIBRARY} not found in build-native/. Build it first: `- + 'node build-tools/cli.js native --quickjs <dir> --dawn <src> --dawn-build <build>.');- }-- const dawnBuild = options.dawnBuild || process.env.ESTELLA_DAWN_BUILD;- if (!dawnBuild) throw new Error('Pass --dawn-build <dir> (or set ESTELLA_DAWN_BUILD) — the APK ships libwebgpu_dawn.so.');- const dawnLib = path.join(dawnBuild, 'src', 'dawn', 'native', 'libwebgpu_dawn.so');- if (!existsSync(dawnLib)) throw new Error(`Dawn library not found: ${dawnLib}.`);-- const sdk = requireSdk();- const ndk = requireNdk(sdk);- const abi = options.abi || 'arm64-v8a';- const platform = options.platform || 'android-33';-- const staging = path.join(buildDir, 'apk');- const libDir = path.join(staging, 'lib', abi);- await rm(staging, { recursive: true, force: true });- await mkdir(libDir, { recursive: true });-- logger.step('Staging the native libraries...');- await copyFile(ndkLibcxxShared(ndk), path.join(libDir, 'libc++_shared.so'));- // Both carry debug info an APK does not need, and the host's is most of its- // size. Shipping it unstripped also broke installing onto a clean device --- // the extract step gave up on the payload -- which only reproduced on a first- // install, since replacing an existing package never re-extracted it.- for (const [src, dst] of [[library, HOST_LIBRARY], [dawnLib, 'libwebgpu_dawn.so']]) {- await runCommand(ndkTool(ndk, 'llvm-strip'), [- '--strip-all', '-o', path.join(libDir, dst), src,- ]);- }-- // assets/ is what the host's readAsset() sees, and what goes in is an editor- // export — cooked assets + manifests + scenes + game.config.json. A whole-- // directory copy, so nothing here carries a file list that could drift from- // what the export actually wrote.- if (!options.content) {- // Nothing to run: the host boots game.config.json and there is no built-in- // fallback, by design — the packaged game takes the same path every real- // game takes.- throw new Error('The host needs a project to run: pass --content <dir> from '- + "Package Project -> Android (or `exportGame({ platform: 'android' })`).");- }- const content = path.isAbsolute(options.content) ? options.content : path.join(rootDir, options.content);- if (!existsSync(content)) throw new Error(`--content dir not found: ${content}`);- await cp(content, path.join(staging, 'assets'), { recursive: true });- logger.step(`Staging exported content from ${path.relative(rootDir, content)}...`);-- // The bundle's bytecode, if this machine could build it. Without it the first- // launch spends ~14 s parsing the bundle before anything is drawn; with it the- // host reads the compile straight off and the first launch matches the rest.- // Absent is a valid state — the host falls back to compiling (see Runtime.cpp).- const bytecode = path.join(rootDir, 'build-native', 'gen', BYTECODE_FILE);- if (existsSync(bytecode)) {- await cp(bytecode, path.join(staging, 'assets', BYTECODE_FILE));- logger.step('Staging the precompiled SDK bytecode...');- } else {- logger.warn('No precompiled bytecode: the first launch will compile the bundle '- + '(~14 s of black screen). Install a host C compiler to avoid it.');- }-- // The app the content asks to be: identity, version, and the orientation the- // OS must lock the window to. The manifest is a template because all four vary- // per project — a static one is why every example installed over the last.- logger.step('Compiling the Java shim (javac + d8)...');- const hasDex = await compileJavaShim(staging, {- sdk, androidPlatform: platform, jdk: options.jdk, root: rootDir,- });- if (!hasDex) logger.warn('No classes.dex: the app will have no soft keyboard (typing is off).');-- const app = readAppConfig(content, (m) => logger.warn(m));- const manifest = path.join(staging, 'AndroidManifest.xml');- await writeFile(manifest, fillTemplate(readFileSync(path.join(rootDir, MANIFEST_TEMPLATE), 'utf8'), {- APP_ID: app.id,- APP_NAME: app.name,- VERSION_NAME: app.version,- VERSION_CODE: app.versionCode,- SCREEN_ORIENTATION: androidScreenOrientation(app.orientation),- HAS_CODE: hasDex ? 'true' : 'false',- }));- logger.info(`App: ${app.name} (${app.id}) v${app.version} — ${app.orientation}`);-- const unsigned = path.join(staging, 'unsigned.apk');- const aligned = path.join(buildDir, apkName(app.id));- logger.step('Linking resources (aapt2)...');- // aapt2 produces the base APK from the manifest alone; the payload (libraries- // and assets) is added below, where the entry names are ours to control.- await runCommand(buildTool(sdk, 'aapt2'), [- 'link',- '--manifest', manifest,- '-I', platformJar(sdk, platform),- '-o', unsigned,- ]);-- logger.step('Adding the native libraries and the game...');- await addToApk(unsigned, staging, ['lib', 'assets', ...(hasDex ? ['classes.dex'] : [])], options.jdk);-- logger.step('Aligning + signing...');- await rm(aligned, { force: true });- await runCommand(buildTool(sdk, 'zipalign'), ['-f', '4', unsigned, aligned]);- const keystore = options.keystore || await debugKeystore(options.jdk);- // apksigner is a launcher script that finds java through JAVA_HOME; hand it the- // JDK we located so it works on a machine that never exported one.- const home = javaHome(options.jdk);- await runCommand(buildTool(sdk, 'apksigner'), [- 'sign', '--ks', keystore,- ...(options.keystore ? [] : ['--ks-pass', 'pass:android', '--key-pass', 'pass:android',- '--ks-key-alias', 'androiddebugkey']),- aligned,- ], home ? { env: { ...process.env, JAVA_HOME: home } } : undefined);-- logger.success(`APK: ${path.relative(rootDir, aligned)}`);- logger.info('Install it with: adb install -r ' + path.relative(rootDir, aligned));-}diff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.tsindex ad94f5629..9ff0f72a3 100644--- a/desktop/electron/exportGame.ts+++ b/desktop/electron/exportGame.ts@@ -38,6 +38,8 @@ import type { OnExportProgress } from './exportProgress';import { ESENGINE_EXTERNAL } from './esengineResolve';import { orientationCss, orientationOverlayHtml, orientationLockScript, orientationLockCspHash, type ScreenOrientation } from './orientationHtml';import { emitIosXcodeProject, type IosProjectSources } from '../../build-tools/utils/iosProject.js';+import { assembleApk, apkFileName } from '../../build-tools/utils/apk.js';+import { debugSigningKey, type SigningKey } from '../../build-tools/utils/androidKeystore.js';import { isNativePlatform, type ExportPlatform } from '../src/project/platforms';import { collectSubsystems, subsystemGapWarnings, targetGaps, type Subsystem } from '../src/project/targetSupport';export type { ExportPlatform };@@ -151,9 +153,12 @@ export interface ExportGameResult {included: number;warnings: string[];errors: string[];- /** iOS: the generated `.xcodeproj`, for the editor to open. Absent when the- * engine is not built for iOS here (the export still carries its content). */+ /** iOS: the generated `.xcodeproj`, for the editor to open. Absent when no iOS+ * runtime template is installed (the export still carries its content). */xcodeProject?: string;+ /** Android: the signed APK. Absent when no Android runtime template is+ * installed (the export still carries its content). */+ apkFile?: string;/** Playable, zip-delivery networks: the archive written beside the HTML — the file* the network takes an upload of. */zipFile?: string;@@ -417,6 +422,12 @@ export async function exportGame(opts: {/** iOS: where the prebuilt engine + app shell live, so the export can wrap* itself in an Xcode project. Omitted (or null) exports content only. */iosSources?: IosProjectSources | null;+ /** Android: the installed runtime template the APK is assembled from. Omitted+ * (or null) exports content only. */+ androidTemplate?: { dir: string; abi: string } | null;+ /** Android: the identity to sign with. Omitted uses the development key, which+ * installs on a device and is refused by every store. */+ androidKey?: SigningKey;}): Promise<ExportGameResult> {const platform = opts.platform ?? 'web';const title = opts.title ?? 'Game';@@ -521,6 +532,7 @@ export async function exportGame(opts: {const errors: string[] = [];/** iOS: set once the project is written around the content (see below). */let xcodeProject: string | undefined;+ let apkFile: string | undefined;await mkdir(payloadDir, { recursive: true });const common: BuildOptions = {bundle: true,@@ -644,10 +656,10 @@ export async function exportGame(opts: {};await writeFile(path.join(payloadDir, 'app.config.json'), JSON.stringify(appConfig, null, 2) + '\n');- // iOS: wrap the content in a project the user can open. Needs no compiler —- // the engine is a prebuilt xcframework — so it belongs here rather than behind- // a command the user has to find and type. An install that never built the- // engine for iOS still exports its content, and says what is missing.+ // Both mobile targets finish the job here, out of the installed runtime+ // template: assembling an app is copying files and writing two formats, so it+ // belongs in the export rather than behind a command the user has to find. An+ // install with no template still exports its content, and says so.if (platform === 'ios') {progress({ phase: 'Writing Xcode project' });const sources = opts.iosSources ?? null;@@ -660,6 +672,22 @@ export async function exportGame(opts: {+ 'Project, then export again.');}}++ if (platform === 'android') {+ progress({ phase: 'Assembling the APK' });+ const template = opts.androidTemplate ?? null;+ if (template) {+ const key = opts.androidKey ?? debugSigningKey();+ apkFile = path.join(absOut, apkFileName(appConfig.id));+ await writeFile(apkFile, assembleApk({+ templateDir: template.dir, contentDir: absOut, app: appConfig, abi: template.abi, key,+ }));+ } else {+ warnings.push('No Android runtime template is installed for this editor version, so no APK '+ + 'was assembled — the content is here. Install one from the Android row in Package '+ + 'Project, then export again.');+ }+ }}// 6. Desktop: wrap the payload in a runnable Electron app.@@ -667,6 +695,6 @@ export async function exportGame(opts: {return {ok: errors.length === 0, platform, outDir: absOut, included: cook.included.length,- warnings, errors, ...(xcodeProject ? { xcodeProject } : {}),+ warnings, errors, ...(xcodeProject ? { xcodeProject } : {}), ...(apkFile ? { apkFile } : {}),};}diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex 352540c9e..5b160528c 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -32,7 +32,7 @@ import { startProjectWatch, stopProjectWatch } from './projectWatcher';import { importAssets, createAsset, IMPORT_EXTENSIONS } from './importAssets';import { exportGame } from './exportGame';import {- iosSourcesFromTemplate, installNativeTemplate, listNativeTemplates, removeNativeTemplate,+ iosSourcesFromTemplate, resolveNativeTemplate, installNativeTemplate, listNativeTemplates, removeNativeTemplate,} from './nativeTemplates';import { loopbackServer, closeAllLoopbackServers } from './loopbackServer';import { httpContentType } from './mimeTypes';@@ -894,6 +894,14 @@ ipcMain.handle(// installed for this editor version — the export then says so instead of// writing a project that cannot link.iosSources: opts?.platform === 'ios' ? iosSourcesFromTemplate(app.getVersion()) : null,+ // Android assembles the APK outright — the template carries everything the+ // package needs, and signing is ours to do.+ androidTemplate: opts?.platform === 'android'+ ? (() => {+ const template = resolveNativeTemplate('android', app.getVersion());+ return template ? { dir: template.dir, abi: template.manifest.abi } : null;+ })()+ : null,onProgress: (p) => e.sender.send('project:exportProgress', p),});},diff --git a/desktop/electron/platformCatalog.ts b/desktop/electron/platformCatalog.tsindex 168050334..542552a7d 100644--- a/desktop/electron/platformCatalog.ts+++ b/desktop/electron/platformCatalog.ts@@ -21,7 +21,7 @@* vendor-neutral (exportMiniGame), so a project platform is a data literal* merged over MINIGAME_PROFILE_DEFAULTS, not a fork of anything.*/-import { existsSync, readdirSync } from 'node:fs';+import { existsSync } from 'node:fs';import { readdir, mkdir, writeFile } from 'node:fs/promises';import path from 'node:path';import { pathToFileURL } from 'node:url';@@ -77,29 +77,6 @@ export interface PlatformStatus {* Windows `build\wasm\acme` reads worse than `build/wasm/acme`. */const posix = (p: string): string => p.split(path.sep).join('/');-/**- * The Android SDK, the way `build-tools/utils/android.js` finds it. Duplicated- * rather than imported: build-tools is not shipped inside the packaged editor,- * and the two answer different questions — that module locates a tool it is- * about to RUN, this one reports whether the developer could run it at all.- */-function androidSdkDir(): string | null {- const env = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;- if (env && existsSync(env)) return env;- const dflt = path.join(process.env.LOCALAPPDATA || process.env.HOME || '', 'Android', 'Sdk');- return existsSync(dflt) ? dflt : null;-}--/** Whether the SDK has an NDK — the APK's `.so` payload is cross-compiled with it. */-function hasNdk(sdk: string): boolean {- const dir = path.join(sdk, 'ndk');- try {- return existsSync(dir) && readdirSync(dir).length > 0;- } catch {- return false;- }-}-/** A built-in target's runtime dependency, as a real file probe. */function builtinReadiness(id: string, dirs: PlatformRuntimeDirs, engineVersion: string,@@ -126,14 +103,12 @@ function builtinReadiness(? { ready: true }: { ready: false, prereq: { kind: 'runtime-missing', dir: posix(dirs.wechat), looked: ['esengine.wxgame.js'], command: 'node build-tools/cli.js build -t wechat' } };- case 'android': {- // The app is built from source with the NDK; there is no staged runtime to- // probe, so the honest question is whether this machine has the toolchain- // that assembles the APK.- const sdk = androidSdkDir();- if (!sdk) return { ready: false, prereq: { kind: 'toolchain-missing', tool: 'android-sdk' } };- return hasNdk(sdk) ? { ready: true } : { ready: false, prereq: { kind: 'toolchain-missing', tool: 'android-ndk' } };- }+ case 'android':+ // The runtime template is the whole prerequisite: the APK is assembled and+ // signed here, on any OS, with nothing from the Android SDK.+ return resolveNativeTemplate('android', engineVersion)+ ? { ready: true }+ : { ready: false, prereq: { kind: 'template-missing', id: templateId('android', DEFAULT_ABI.android), version: engineVersion } };case 'ios': {// The template comes first because it is the harder blocker: without it thediff --git a/desktop/src/components/BuildDialog.tsx b/desktop/src/components/BuildDialog.tsxindex 7eab027c8..68394697b 100644--- a/desktop/src/components/BuildDialog.tsx+++ b/desktop/src/components/BuildDialog.tsx@@ -55,6 +55,8 @@ interface Result {errors: string[];/** iOS: the .xcodeproj the export wrote around its content. */xcodeProject?: string;+ /** Android: the signed APK the export assembled. */+ apkFile?: string;}/** Nav groupings. Order here is the order they appear. */@@ -153,8 +155,6 @@ const mb = (bytes: number): string => `${(bytes / 1024 / 1024).toFixed(1)} MB`;/** Localized names for the native toolchain pieces the main process probes. */const TOOLCHAIN_TEXT: Record<NativeToolchain, string> = {- 'android-sdk': t('build.needAndroidSdk'),- 'android-ndk': t('build.needAndroidNdk'),xcode: t('build.needXcode'),macos: t('build.needMacos'),};@@ -873,9 +873,11 @@ export function BuildDialog() {<div className="build__next selectable">{result.xcodeProject? t('build.next.iosProject')- : result.zipFile- ? t('build.next.playableZip')- : def.next(result.outDir)}+ : result.apkFile+ ? t('build.next.apk', { apk: result.apkFile })+ : result.zipFile+ ? t('build.next.playableZip')+ : def.next(result.outDir)}</div>{result.ok && (<div className="build__actions">@@ -889,6 +891,11 @@ export function BuildDialog() {<ExternalLink size={13} /> {t('build.openXcode')}</Button>)}+ {result.apkFile && (+ <Button variant="primary" onClick={() => void window.estella.shell?.showItem?.(result.apkFile!)}>+ <FolderOpen size={13} /> {t('build.showApk')}+ </Button>+ )}<Button onClick={() => void window.estella.shell?.openPath?.(result.outDir)}><FolderOpen size={13} /> {t('build.openFolder')}</Button>diff --git a/desktop/src/i18n/messages/project.ts b/desktop/src/i18n/messages/project.tsindex 86540c946..5da12a5e9 100644--- a/desktop/src/i18n/messages/project.ts+++ b/desktop/src/i18n/messages/project.ts@@ -33,14 +33,6 @@ export const projectMessages = defineMessages({// — Native toolchain readiness. A native target's export is app CONTENT, which// always succeeds; only assembling the installable app needs these, and that// step can run on another machine. —- 'build.needAndroidSdk': {- en: 'Android SDK not found — set ANDROID_HOME, or install it with Android Studio.',- zh: '未找到 Android SDK——请设置 ANDROID_HOME,或通过 Android Studio 安装。',- },- 'build.needAndroidNdk': {- en: 'No NDK in the Android SDK — install one from the SDK Manager (the app is cross-compiled with it).',- zh: 'Android SDK 中没有 NDK——请在 SDK Manager 中安装(应用由它交叉编译)。',- },'build.needXcode': {en: 'Xcode not found — the iOS app is built and signed by it.',zh: '未找到 Xcode——iOS 应用由它构建并签名。',@@ -159,9 +151,14 @@ export const projectMessages = defineMessages({},'build.next.android': {- en: 'Build the signed APK around it: node build-tools/cli.js native --package --content {out} (see native/README.md for the one-time Dawn + QuickJS setup).',- zh: '据此构建签名 APK:node build-tools/cli.js native --package --content {out}(一次性的 Dawn + QuickJS 准备见 native/README.md)。',+ en: 'The content is in {out}. Install the Android runtime template to get a signed APK assembled around it.',+ zh: '内容已写入 {out}。安装 Android 运行时模板后,导出会围绕它装配出已签名的 APK。',+ },+ 'build.next.apk': {+ en: 'Signed APK: {apk} — install it with adb install -r, or copy it to the device.',+ zh: '已签名 APK:{apk} —— 用 adb install -r 安装,或直接拷到设备上。',},+ 'build.showApk': { en: 'Show APK', zh: '显示 APK' },'build.next.ios': {en: 'The content is in {out}. Install the iOS runtime template to get an Xcode project written around it.',zh: '内容已写入 {out}。安装 iOS 运行时模板后,导出会围绕它写出 Xcode 工程。',diff --git a/desktop/src/project/platforms.ts b/desktop/src/project/platforms.tsindex 4ab59429d..c043a83f4 100644--- a/desktop/src/project/platforms.ts+++ b/desktop/src/project/platforms.ts@@ -114,4 +114,4 @@ export type PlatformPrereq =};/** The native toolchain pieces the editor probes for. */-export type NativeToolchain = 'android-sdk' | 'android-ndk' | 'xcode' | 'macos';+export type NativeToolchain = 'xcode' | 'macos';