From 0d63a720f651d44ffe23b5120df06b9e5c08e1aa Mon Sep 17 00:00:00 2001 From: Marcus Rehbock Date: Fri, 7 Aug 2026 16:54:22 -0700 Subject: [PATCH] Config plugin: pin local JDK 17/21 for Gradle when present RN's CMake tooling fails on JDK 24+ (restricted native access), so prebuild injects org.gradle.java.home pointing at ~/.jdks/jdk-21* when one exists. Co-Authored-By: Claude Fable 5 --- plugins/with-release-signing.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/with-release-signing.js b/plugins/with-release-signing.js index 5270aa5..27fecee 100644 --- a/plugins/with-release-signing.js +++ b/plugins/with-release-signing.js @@ -2,7 +2,10 @@ Keystore: $HEALTH_KEYSTORE or ~/.android-keys/health-app-release.jks Password: $KEYSTORE_PASSWORD or ~/.android-keys/health-app-release.password Falls back to the debug keystore when neither exists. */ -const { withAppBuildGradle } = require('expo/config-plugins'); +const { withAppBuildGradle, withGradleProperties } = require('expo/config-plugins'); +const fs = require('fs'); +const os = require('os'); +const path = require('path'); const SIGNING = ` release { // keystore lives outside the repo; password from env or ~/.android-keys @@ -18,7 +21,27 @@ const SIGNING = ` release { } }`; +/* RN's CMake tooling breaks on JDK 24+ (native-access restrictions); pin a + local JDK 17–21 for Gradle when one is present under ~/.jdks. */ +function findJdk21() { + const dir = path.join(os.homedir(), '.jdks'); + if (!fs.existsSync(dir)) return null; + const hit = fs + .readdirSync(dir) + .filter((d) => /^jdk-(17|21)/.test(d)) + .sort() + .pop(); + return hit ? path.join(dir, hit) : null; +} + module.exports = function withReleaseSigning(config) { + config = withGradleProperties(config, (cfg) => { + const jdk = findJdk21(); + if (jdk && !cfg.modResults.some((p) => p.key === 'org.gradle.java.home')) { + cfg.modResults.push({ type: 'property', key: 'org.gradle.java.home', value: jdk }); + } + return cfg; + }); return withAppBuildGradle(config, (cfg) => { let g = cfg.modResults.contents; if (!g.includes('def ksPath')) {