fix(android): patch gradle for capacitor core

This commit is contained in:
DeskClaw Bot
2026-04-21 16:36:06 +00:00
Unverified
parent 6b982a7486
commit 10cde56b6d
2 changed files with 27 additions and 2 deletions

View File

@@ -9,7 +9,8 @@
"web:sync": "node scripts/sync-web.mjs", "web:sync": "node scripts/sync-web.mjs",
"android:init": "pnpm install && pnpm exec cap init DeskClaw dev.deskclaw.app --web-dir=www --npm-client=pnpm", "android:init": "pnpm install && pnpm exec cap init DeskClaw dev.deskclaw.app --web-dir=www --npm-client=pnpm",
"android:add": "pnpm exec cap add android", "android:add": "pnpm exec cap add android",
"android:sync": "pnpm exec cap sync android", "android:patch": "node scripts/patch-android.mjs",
"android:sync": "pnpm exec cap sync android && pnpm run android:patch",
"android:apk:debug": "cd android && ./gradlew assembleDebug", "android:apk:debug": "cd android && ./gradlew assembleDebug",
"android:apk:release": "cd android && ./gradlew assembleRelease" "android:apk:release": "cd android && ./gradlew assembleRelease"
}, },
@@ -21,4 +22,3 @@
"@capacitor/cli": "^7.4.3" "@capacitor/cli": "^7.4.3"
} }
} }

View File

@@ -0,0 +1,25 @@
import { readFile, writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
async function main() {
const scriptDir = fileURLToPath(new URL('.', import.meta.url))
const mobileRoot = resolve(scriptDir, '..')
const appGradle = resolve(mobileRoot, 'android', 'app', 'build.gradle')
let text = await readFile(appGradle, 'utf8')
const before = "implementation project(':capacitor-android')"
const after = 'implementation "com.capacitorjs:core:7.6.2"'
if (text.includes(after)) return
if (!text.includes(before)) return
text = text.replace(before, after)
await writeFile(appGradle, text, 'utf8')
}
main().catch((err) => {
console.error(err)
process.exit(1)
})