Sanniv Khare 8 min read

React Native 0.89 deprecates invokeJavaMethod: fix C++ modules

React Native 0.89 deprecates invokeJavaMethod: fix C++ modules

React Native 0.89 marks the old JavaTurboModule::invokeJavaMethod overload, the one that takes a jmethodID& cachedMethodID, as [[deprecated]]. Library C++ is compiled with -Wall -Werror, so any Android module that still ships code generated by codegen 0.88 or earlier stops building. The fix is one argument: drop cachedMethodId from each call, or guard the call by React Native version if the library must still support 0.88.

We checked this on React Native 0.89.0-rc.3 (published 23 November; 0.89.0 final is planned for 7 December) by diffing the npm packages of react-native 0.88.1 and 0.89.0-rc.3 and of @react-native/codegen for both versions, scanning 26 library package versions, and building a fresh 0.89.0-rc.3 app with react-native-maps 1.29.11 on our M1 lab Mac. Unpatched, the Android release build failed with 7 errors in 36 seconds; with the one-argument fix it built.

Why we did this: our banking and TV apps carry Android native modules with hand-kept C++, and the maps and Firebase libraries appear in the kind of client apps we upgrade each release. We want to know what breaks before the 0.89 upgrade starts, not during it.

What changed in JavaTurboModule.h

In 0.88.1 there is one invokeJavaMethod. Generated code keeps a static jmethodID per method and passes it in by reference, so React Native can fill it on the first call. In 0.89.0-rc.3 the header in ReactCommon/react/nativemodule/core/platform/android/ReactCommon/ has two overloads:

// Looks the method up on its first call and caches it by name.
jsi::Value invokeJavaMethod(
    jsi::Runtime &runtime,
    TurboModuleMethodValueKind valueKind,
    const char *methodName,
    const char *methodSignature,
    const jsi::Value *args,
    size_t argCount);

// Kept for code generated by earlier versions of codegen and for modules
// that call it directly. cachedMethodID is neither read nor written: the
// method is cached by name.
[[deprecated("Use the overload without cachedMethodID")]]
jsi::Value invokeJavaMethod(
    jsi::Runtime &runtime,
    TurboModuleMethodValueKind valueKind,
    const std::string &methodName,
    const std::string &methodSignature,
    const jsi::Value *args,
    size_t argCount,
    jmethodID &cachedMethodID);

The new class keeps a methodInfos_ map (method ID, parsed argument types and return type) behind a mutex, keyed by method name. The old overload now forwards to the new one and ignores the ID you pass. So the old call still works at runtime; it only fails at compile time when warnings are errors.

Two smaller changes in the same .cpp:

  • When the Java method cannot be found, 0.89 adds an explicit jsi::JSError (“Unable to find method … on “) after the JNI error check, so a signature mismatch surfaces as a JavaScript error naming the module.
  • The JNI signature is parsed once per method and reused, where 0.88.1 re-parsed the argument types on every call.

The header also changes its includes: it pulls in <react/cxxstableapi/UmbrellaGuard.h>, <React/Bridging.h> and <React/CallInvoker.h>, and drops the direct include of react/bridging/CallbackWrapper.h. In rc.3 that is harmless for existing code: the old ReactCommon/CallInvoker.h still ships, React/Bridging.h includes CallbackWrapper.h, and the umbrella guard is inert unless a build defines RN_STRICT_API.

Codegen 0.89 already emits the new call

We diffed GenerateModuleJniCpp.js in @react-native/codegen 0.88.1 and 0.89.0-rc.3. The template loses the static cache and the seventh argument:

The generated JNI call in codegen 0.88 and 0.89, side by side

Codegen 0.88 passes a static cachedMethodId; codegen 0.89 calls the six-argument overload.

This matters for who is affected. A library that lets React Native run codegen at app build time gets fresh 0.89 output and compiles cleanly. A library that checks its generated JNI files into the package (with includesGeneratedCode or its own cmakeListsPath) keeps the 0.88-style calls until its authors regenerate.

Why it is an error, not a warning

ReactCommon/cmake-utils/react-native-flags.cmake is identical in 0.88.1 and 0.89.0-rc.3. Its flag list starts with -Wall -Werror, and target_compile_reactnative_options() applies that list to any target that calls it. Clang reports use of a [[deprecated]] function by default, and -Werror makes it fatal.

Which libraries ship the old call

We ran npm pack on 26 package versions that are common in the apps we build and grepped their android/ folders for cachedMethodId (27 November 2026):

Library scan: which packages still ship the old invokeJavaMethod call

Only react-native-maps 1.29.11 and Firebase 27.1.1 ship the old call unguarded.

  • react-native-maps 1.29.11 (latest on npm): 7 unguarded calls in android/src/main/jni/RNMapsSpecs-generated.cpp, compiled with target_compile_reactnative_options.
  • @react-native-firebase/app and messaging 27.1.1: 23 calls each in checked-in codegen output, same flags.
  • @react-native-firebase/* 27.2.0 (25 November): still the old calls, plus one CMake line, -Wno-error=deprecated-declarations, with the comment “React Native 0.89+ deprecates the cached-method-ID overload used by this checked-in codegen output; older React Native versions still need it.”
  • react-native-svg 15.16.1: already fixed with a guard. CMake passes REACT_NATIVE_MINOR_VERSION, and every call sits under #if REACT_NATIVE_MINOR_VERSION >= 89.
  • The other 21 (screens, safe-area-context, gesture-handler, reanimated, worklets, mmkv, async-storage, vision-camera, flash-list, webview, netinfo, lottie, device-info, nitro-modules, keychain, biometrics, datetimepicker, pager-view, Sentry, Stripe, permissions): no checked-in cachedMethodId calls.

The build on our lab Mac

To see the failure rather than infer it, we built a fresh React Native 0.89.0-rc.3 app with react-native-maps 1.29.11 and react-native-svg 15.16.1 on our M1 lab Mac (macOS 15.7.3, JDK 17.0.21, Gradle 9.4.1, NDK 28.2.13676358), as an Android release build for arm64-v8a.

Android release build output: 7 deprecation errors in react-native-maps

Real output from our lab build, with file paths shortened.

  • Unpatched: buildCMakeRelWithDebInfo failed with 7 errors, one per invokeJavaMethod call in RNMapsSpecs-generated.cpp. Gradle reported BUILD FAILED in 36 s.
  • Patched (each call without cachedMethodId, nothing else changed): BUILD SUCCESSFUL in 56 s, an incremental build on top of the failed one. The APK carries libreact_codegen_rnsvg.so next to the app’s own native library, so react-native-svg‘s guarded file compiled as shipped.

Both numbers are one run on one Mac, after an earlier build of the same app had warmed the Gradle cache.

Installing react-native-maps into the rc app also needed --legacy-peer-deps: npm does not treat 0.89.0-rc.3 as matching the library’s >= 0.76.0 peer range, because it is a prerelease. That goes away with 0.89.0 final.

Three ways to fix it

1. Regenerate, or drop the argument (0.89 and later only)

If your module only has to build on 0.89+, rerun codegen with @react-native/codegen 0.89, or edit each call by hand: delete the static jmethodID cachedMethodId = nullptr; line and the last argument.

static jsi::Value __hostFunction_MyModuleSpecJSI_getCamera(
    jsi::Runtime &rt, TurboModule &turboModule,
    const jsi::Value *args, size_t count) {
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(
      rt, PromiseKind, "getCamera",
      "(DLcom/facebook/react/bridge/Promise;)V", args, count);
}

This does not compile against 0.88 or earlier, where the six-argument overload does not exist.

2. Guard by version (libraries that support both)

This is what react-native-svg 15.16.1 does. Pass the minor version from CMake, then keep both calls:

target_compile_definitions(
  react_codegen_mymodule
  PRIVATE
  REACT_NATIVE_MINOR_VERSION=${ReactAndroid_VERSION_MINOR}
)
#if REACT_NATIVE_MINOR_VERSION >= 89
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(
      rt, PromiseKind, "getCamera", "(D...)V", args, count);
#else
  static jmethodID cachedMethodId = nullptr;
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(
      rt, PromiseKind, "getCamera", "(D...)V", args, count, cachedMethodId);
#endif

Replace (D...)V with the real JNI signature from your generated file.

3. Tolerate the warning (a stopgap)

This is the React Native Firebase 27.2.0 approach: leave the code and turn the one warning back into a warning for that target.

target_compile_reactnative_options(react_codegen_mymodule PRIVATE)
target_compile_options(react_codegen_mymodule PRIVATE
  -Wno-error=deprecated-declarations)

It is the smallest change and keeps 0.88 support, but it also hides any other deprecation in that target, and the old overload will be removed at some point.

If the library is not yours

For a dependency that has not shipped a fix (today, react-native-maps 1.29.11), patch the generated file with patch-package the same way we did in the lab: remove the static cache line and the seventh argument in each of the 7 calls. Keep the patch next to an issue link so you know when to drop it. For Firebase, upgrade to 27.2.0 before or with the React Native upgrade.

What to check on your own app before 7 December

  1. Search your app and node_modules for cachedMethodId in .cpp files under android/.
  2. For each hit, check whether the file is generated at build time (under build/generated) or shipped in the package. Only shipped files need action.
  3. Check whether the target uses target_compile_reactnative_options or -Werror. If it does, the 0.89 build will fail.
  4. Pick fix 1, 2 or 3 per module, and build a release APK for one ABI (-PreactNativeArchitectures=arm64-v8a) to confirm.
  5. Hand-written C++ that calls invokeJavaMethod directly (for example a module that wraps a Java SDK) needs the same change; codegen will not touch it.

Made by the team behind this post

Apps from our studio

  • Goes with this post

    BMDB.fun

    Your Bollywood world at a glance, with links straight to the OTT app that streams each film.

    Android TV · Web · Mobile

    Get
  • Nix

    The Mac uninstaller that finds what the Trash leaves behind: caches, logs, derived data and saved states.

    macOS

    Get
  • Cardigami

    Pop-up greeting cards that rise out of the fold on iPhone Duo.

    iPhone · App Store

    Get
  • OneClick QuitAll

    Quit every running app in one click. See memory and CPU first.

    macOS · Mac App Store

    Get

Need this built? Let’s talk.

We build and run apps for Mac, TV, mobile and the web, and write about what we learn.