Skip to content

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.

fix(android): every Android package fills its manifest from one list

esengine172fc52fc54d
diff --git a/build-tools/utils/aab.js b/build-tools/utils/aab.js
index 806c19d8e..94b218ab0 100644
--- a/build-tools/utils/aab.js
+++ b/build-tools/utils/aab.js
@@ -25,7 +25,7 @@ import { compileProtoManifest } from './androidProtoXml.js';
import { appResources } from './androidResources.js';
import { DEFAULT_ICON, templateAbis } from './nativeTemplate.js';
import { jarSignatureFiles } from './jarSign.js';
-import { fillTemplate, androidScreenOrientation } from './nativeApp.js';
+import { fillTemplate, androidManifestValues } from './nativeApp.js';
/**
* BundleConfig.pb — `bundletool { version = 2 }`, `compression { uncompressed_glob = 1 }`.
@@ -54,13 +54,7 @@ export function assembleAab(options) {
const manifest = compileProtoManifest(fillTemplate(
readFileSync(path.join(templateDir, 'AndroidManifest.xml.in'), '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',
- USES_CLEARTEXT: app.allowHttp ? 'true' : 'false',
+ ...androidManifestValues(app, { hasCode: hasDex }),
}), resources.references);
// Every architecture: Play splits the bundle per device, which is what the
diff --git a/build-tools/utils/apk.js b/build-tools/utils/apk.js
index 2170650b1..427825902 100644
--- a/build-tools/utils/apk.js
+++ b/build-tools/utils/apk.js
@@ -22,7 +22,7 @@ import { makeZip, zipLayout } from './zip.js';
import { compileManifest } from './androidBinaryXml.js';
import { appResources } from './androidResources.js';
import { DEFAULT_ICON, templateAbis } from './nativeTemplate.js';
-import { fillTemplate, androidScreenOrientation } from './nativeApp.js';
+import { fillTemplate, androidManifestValues } from './nativeApp.js';
/** The boundary a mapped `.so` must start on — a 16 KiB page, which every
* smaller page size also divides. */
@@ -149,13 +149,7 @@ export function assembleApk(options) {
const manifest = compileManifest(fillTemplate(
readFileSync(path.join(templateDir, 'AndroidManifest.xml.in'), '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',
- USES_CLEARTEXT: app.allowHttp ? 'true' : 'false',
+ ...androidManifestValues(app, { hasCode: hasDex }),
}), resources.references);
// Every architecture the template carries, so one package installs on a phone
diff --git a/build-tools/utils/gradleProject.js b/build-tools/utils/gradleProject.js
index 244a597e8..f48521903 100644
--- a/build-tools/utils/gradleProject.js
+++ b/build-tools/utils/gradleProject.js
@@ -13,7 +13,7 @@
import { cp, mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import path from 'node:path';
-import { fillTemplate, androidScreenOrientation } from './nativeApp.js';
+import { fillTemplate, androidManifestValues } from './nativeApp.js';
/** Android Gradle Plugin the emitted project asks for. */
const AGP_VERSION = '8.7.3';
@@ -44,15 +44,8 @@ function projectName(appName) {
* @returns {{xml: string, minSdk: number, targetSdk: number}}
*/
export function gradleManifest(templateXml, app) {
- const filled = fillTemplate(templateXml, {
- APP_ID: app.id,
- APP_NAME: app.name,
- VERSION_NAME: app.version,
- VERSION_CODE: app.versionCode,
- SCREEN_ORIENTATION: androidScreenOrientation(app.orientation),
- // A project compiles the Java shim from source, so there is always code.
- HAS_CODE: 'true',
- });
+ // A project compiles the Java shim from source, so there is always code.
+ const filled = fillTemplate(templateXml, androidManifestValues(app, { hasCode: true }));
const minSdk = Number(/android:minSdkVersion="(\d+)"/.exec(filled)?.[1] ?? 29);
const targetSdk = Number(/android:targetSdkVersion="(\d+)"/.exec(filled)?.[1] ?? 33);
diff --git a/build-tools/utils/nativeApp.js b/build-tools/utils/nativeApp.js
index 15aad1728..a7d8d74a4 100644
--- a/build-tools/utils/nativeApp.js
+++ b/build-tools/utils/nativeApp.js
@@ -73,6 +73,23 @@ export function iosInterfaceOrientations(orientation) {
: ['UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight'];
}
+/**
+ * The values `AndroidManifest.xml.in` is filled with, for every packager that
+ * writes one (the APK, the App Bundle, the Android Studio project). One list, so
+ * a placeholder added to the template cannot reach one package and not another.
+ */
+export function androidManifestValues(app, { hasCode }) {
+ return {
+ APP_ID: app.id,
+ APP_NAME: app.name,
+ VERSION_NAME: app.version,
+ VERSION_CODE: app.versionCode,
+ SCREEN_ORIENTATION: androidScreenOrientation(app.orientation),
+ HAS_CODE: hasCode ? 'true' : 'false',
+ USES_CLEARTEXT: app.allowHttp ? 'true' : 'false',
+ };
+}
+
/** Substitute `@NAME@` placeholders in a committed template. */
export function fillTemplate(text, values) {
return text.replace(/@([A-Z_]+)@/g, (match, key) => (key in values ? String(values[key]) : match));
diff --git a/desktop b/desktop
index 922145ec6..e99bc068c 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 922145ec6ced6a65c0c7495a6a81d1dd4e412c66
+Subproject commit e99bc068ca3fd25138aee21d143d0723f7805400
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 182098da6..312221a57 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -1134,4 +1134,10 @@ export const NOTED = {
{ note: 'A native Android app can reach the network: its manifest never asked for it, so a remote group\'s assets, hot updates and the debug channel all failed on Android. A development build also allows plain http (a LAN CDN); a shipping build is held to https, and the export warns when its CDN is http.' },
'feat(native): a native build names its device when it connects':
{ note: 'A native development build names its device to the editor — `macOS · Mac16,10`, `Android · Pixel 8` — as web and mini-game builds already did.' },
+ 'feat(build): an Android development build can dial the editor':
+ { note: 'A native Android app can reach the network: its manifest never asked for it, so a remote group\'s assets, hot updates and the debug channel all failed on Android. A development build also allows plain http (a LAN CDN); a shipping build is held to https, and the export warns when its CDN is http.' },
+ 'test(android): a Studio project\'s manifest has every placeholder filled':
+ { internal: 'A test of the generated Android Studio project; nothing a creator sees changes.' },
+ 'fix(android): every Android package fills its manifest from one list':
+ { note: 'A native Android app can reach the network: its manifest never asked for it, so a remote group\'s assets, hot updates and the debug channel all failed on Android. A development build also allows plain http (a LAN CDN); a shipping build is held to https, and the export warns when its CDN is http.' },
};