From 87ffe3c198704289c4b4868d7501cf22085c0399 Mon Sep 17 00:00:00 2001 From: Sriteja Sugoor Date: Mon, 4 May 2026 13:20:57 +0530 Subject: [PATCH 1/2] fix(android): branch RN reflection field names by version (AAP-18921) RN 0.80 renamed several Android-side fields that Detox accesses via reflection. Cherry-picks upstream wix/Detox PR #4812 onto this fork so that: - NetworkingModuleReflected uses `client` for RN >0.79, else `mClient` - JavaTimersReflected uses `reactHost`/`javaTimerManager` for RN >0.79 and `reactInstance` for RN >0.80, else the legacy `m*` names Behaviour is unchanged for RN <=0.79; this unblocks customers on RN 0.80+ who hit `NoSuchFieldException: mClient` at Detox init. Bumps version to 20.38.0-cloud.2. Refs: AAP-18921, https://github.com/wix/Detox/pull/4812 --- .../network/NetworkingModuleReflected.kt | 12 +++++++-- .../timers/JavaTimersReflected.kt | 25 ++++++++++++++++--- detox/package.json | 2 +- package.json | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkingModuleReflected.kt b/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkingModuleReflected.kt index 0a913fac5..b8aa30fff 100644 --- a/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkingModuleReflected.kt +++ b/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkingModuleReflected.kt @@ -3,6 +3,7 @@ package com.wix.detox.reactnative.idlingresources.network import android.util.Log import com.facebook.react.bridge.ReactContext import com.facebook.react.modules.network.NetworkingModule +import com.wix.detox.reactnative.ReactNativeInfo import okhttp3.OkHttpClient import org.joor.Reflect import org.joor.ReflectException @@ -10,13 +11,20 @@ import org.joor.ReflectException private const val LOG_TAG = "RNNetworkingModuleRefl" -private const val FIELD_OKHTTP_CLIENT = "mClient" +private const val FIELD_OKHTTP_CLIENT_PRE80 = "mClient" +private const val FIELD_OKHTTP_CLIENT = "client" internal class NetworkingModuleReflected(private val reactContext: ReactContext) { fun getHttpClient(): OkHttpClient? { val networkNativeModule = reactContext.getNativeModule(NetworkingModule::class.java) try { - return Reflect.on(networkNativeModule).field(FIELD_OKHTTP_CLIENT).get() + val fieldName = if (ReactNativeInfo.rnVersion().minor > 79) { + FIELD_OKHTTP_CLIENT + } else { + FIELD_OKHTTP_CLIENT_PRE80 + } + + return Reflect.on(networkNativeModule).field(fieldName).get() } catch (e: ReflectException) { Log.e(LOG_TAG, "Can't set up Networking Module listener", e) return null diff --git a/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/JavaTimersReflected.kt b/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/JavaTimersReflected.kt index 6d738b99d..a350ab044 100644 --- a/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/JavaTimersReflected.kt +++ b/detox/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/JavaTimersReflected.kt @@ -2,6 +2,7 @@ package com.wix.detox.reactnative.idlingresources.timers import com.facebook.react.bridge.ReactContext import com.facebook.react.modules.core.JavaTimerManager +import com.wix.detox.reactnative.ReactNativeInfo import org.joor.Reflect import kotlin.reflect.full.declaredFunctions import kotlin.reflect.jvm.isAccessible @@ -19,8 +20,26 @@ object JavaTimersReflected { } private fun getTimersManager(reactContext: ReactContext): JavaTimerManager { - val reactHost = Reflect.on(reactContext).field("mReactHost").get() - val reactInstance = Reflect.on(reactHost).field("mReactInstance").get() - return Reflect.on(reactInstance).field("mJavaTimerManager").get() as JavaTimerManager + val reactHostFieldName = if (ReactNativeInfo.rnVersion().minor > 79) { + "reactHost" + } else { + "mReactHost" + } + + val reactInstanceFieldName = if (ReactNativeInfo.rnVersion().minor > 80) { + "reactInstance" + } else { + "mReactInstance" + } + + val javaTimerManagerFieldName = if (ReactNativeInfo.rnVersion().minor > 79) { + "javaTimerManager" + } else { + "mJavaTimerManager" + } + + val reactHost = Reflect.on(reactContext).field(reactHostFieldName).get() + val reactInstance = Reflect.on(reactHost).field(reactInstanceFieldName).get() + return Reflect.on(reactInstance).field(javaTimerManagerFieldName).get() as JavaTimerManager } } diff --git a/detox/package.json b/detox/package.json index 830e92285..63f15be27 100644 --- a/detox/package.json +++ b/detox/package.json @@ -1,7 +1,7 @@ { "name": "@browserstack/detox", "description": "E2E tests and automation for mobile", - "version": "20.38.0", + "version": "20.38.0-cloud.2", "bin": { "detox": "local-cli/cli.js" }, diff --git a/package.json b/package.json index 923c3b9f5..83b153a7b 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "shell-utils": "1.x.x", "unified": "^10.1.0" }, - "version": "20.38.0" + "version": "20.38.0-cloud.2" } From 56cd43b6d190e987c06876101096274ff5aece93 Mon Sep 17 00:00:00 2001 From: Sriteja Sugoor Date: Mon, 4 May 2026 20:29:37 +0530 Subject: [PATCH 2/2] Revert manual version bump; let Jenkins publish job set -cloud.x The DetoxNpmPackagePublish Jenkins job (per Confluence Detox Release Process) is what bumps the version to x.y.z-cloud.X at publish time. Source on release-20.38.0-cloud.1 has always been "20.38.0" without the suffix. Reverting the two package.json version changes. Refs: AAP-18921 --- detox/package.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/detox/package.json b/detox/package.json index 63f15be27..830e92285 100644 --- a/detox/package.json +++ b/detox/package.json @@ -1,7 +1,7 @@ { "name": "@browserstack/detox", "description": "E2E tests and automation for mobile", - "version": "20.38.0-cloud.2", + "version": "20.38.0", "bin": { "detox": "local-cli/cli.js" }, diff --git a/package.json b/package.json index 83b153a7b..923c3b9f5 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,5 @@ "shell-utils": "1.x.x", "unified": "^10.1.0" }, - "version": "20.38.0-cloud.2" + "version": "20.38.0" }