Merge pull request #5 from shumengya/cursor/fix-network-security-config-b4e4
fix(android): 修复 network_security_config 资源缺失导致构建失败
This commit is contained in:
23
.github/scripts/patch-android-system-bars.mjs
vendored
23
.github/scripts/patch-android-system-bars.mjs
vendored
@@ -112,18 +112,19 @@ const NETWORK_SECURITY_XML = `<?xml version="1.0" encoding="utf-8"?>
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function ensureNetworkSecurityXml(androidRoot) {
|
function ensureNetworkSecurityXml(androidRoot) {
|
||||||
const resDirs = walk(androidRoot, (p) => {
|
const resDir = path.join(androidRoot, "app", "src", "main", "res");
|
||||||
const normalized = p.replace(/\\/g, "/");
|
if (!fs.existsSync(resDir)) {
|
||||||
return normalized.endsWith("/app/src/main/res");
|
console.warn(
|
||||||
});
|
`No Android res directory found for network_security_config.xml: ${resDir}`,
|
||||||
|
);
|
||||||
for (const resDir of resDirs) {
|
return;
|
||||||
const xmlDir = path.join(resDir, "xml");
|
|
||||||
fs.mkdirSync(xmlDir, { recursive: true });
|
|
||||||
const target = path.join(xmlDir, "network_security_config.xml");
|
|
||||||
fs.writeFileSync(target, NETWORK_SECURITY_XML);
|
|
||||||
console.log(`Wrote ${path.relative(root, target)}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const xmlDir = path.join(resDir, "xml");
|
||||||
|
fs.mkdirSync(xmlDir, { recursive: true });
|
||||||
|
const target = path.join(xmlDir, "network_security_config.xml");
|
||||||
|
fs.writeFileSync(target, NETWORK_SECURITY_XML);
|
||||||
|
console.log(`Wrote ${path.relative(root, target)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function patchAndroidManifest(androidRoot) {
|
function patchAndroidManifest(androidRoot) {
|
||||||
|
|||||||
Reference in New Issue
Block a user