fix(ci): strip LD_PRELOAD on child QEMU execution and remove rename watcher
Build Android APK / Build Release APKs (push) Failing after 9m49s

This commit is contained in:
2026-09-14 00:27:57 +02:00
parent f810b801ad
commit a3ddd4dfa3
4 changed files with 41 additions and 166 deletions
-48
View File
@@ -44,51 +44,3 @@ tasks.register("clean", Delete) {
delete rootProject.buildDir
}
// Auto-wrap x86_64 AAPT2 on ARM64 Linux hosts (e.g. CI runner) to run seamlessly via QEMU
gradle.taskGraph.whenReady { taskGraph ->
String os = System.getProperty("os.name", "").toLowerCase()
String arch = System.getProperty("os.arch", "").toLowerCase()
if (os.contains("linux") && (arch.contains("aarch64") || arch.contains("arm64"))) {
def qemu = new File("/usr/bin/qemu-x86_64-static").exists() ? "/usr/bin/qemu-x86_64-static" : "qemu-x86_64-static"
def wrapAapt2 = {
def searchDirs = []
def gh = gradle.gradleUserHomeDir
if (gh != null && gh.exists()) {
def transforms = new File(gh, "caches")
if (transforms.exists()) searchDirs.add(transforms)
}
def sdk = new File("/opt/android-sdk-linux/build-tools")
if (sdk.exists()) searchDirs.add(sdk)
def rootGradle = new File("/root/.gradle/caches")
if (rootGradle.exists()) searchDirs.add(rootGradle)
searchDirs.each { dir ->
dir.eachFileRecurse(groovy.io.FileType.FILES) { file ->
if (file.name == "aapt2" && !file.name.endsWith(".orig")) {
try {
byte[] header = new byte[4]
file.withInputStream { is -> is.read(header) }
if (header[0] == 0x7F && header[1] == 0x45 && header[2] == 0x4C && header[3] == 0x46) {
def orig = new File(file.parentFile, "aapt2.orig")
if (!orig.exists()) {
file.renameTo(orig)
orig.setExecutable(true)
}
file.text = "#!/bin/sh\nexec ${qemu} -L /usr/x86_64-linux-gnu \"\$(dirname \"\$0\")/aapt2.orig\" \"\$@\"\n"
file.setExecutable(true)
println "[ARM64 CI] Wrapped AAPT2 at ${file.absolutePath} with QEMU"
}
} catch (Exception ignored) {}
}
}
}
}
taskGraph.allTasks.findAll {
it.name.contains("Resource") || it.name.contains("Aapt") || it.name.contains("Package") || it.name.contains("Bundle")
}.each { task ->
task.doFirst {
wrapAapt2()
}
}
}
}