You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native中react-native-worklets-core已安装仍报未找到错误求助

React Native Android 中 react-native-worklets-core 未被识别的问题

问题背景

正在开发一款使用Google ML Kit姿态检测功能的React Native Android应用,项目初期目标是启动应用并验证姿态检测功能正常运行。为此引入了react-native-vision-camera和react-native-worklets-core用于帧处理器。

帧处理器使用代码

在App.tsx中实现帧处理器:

//[...]
 const frameProcessor = useFrameProcessor((frame: any) => {
    'worklet';
    const poseObject = objectDetect(frame);

 //[...]

Camera组件中引入帧处理器:

return (
    <>
      <Camera
        frameProcessor={frameProcessor}
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={true}
      />
//[...]

报错信息

项目构建成功,但模拟器中应用抛出以下错误:

Uncaught Error

Frame Processors are not available, react-native-worklets-core is not installed! Error: TurboModuleRegistry.getEnforcing(...): 'Worklets' could not be found. Verify that a module by this name is registered in the native binary.
Bridgeless mode: false. TurboModule interop: false. Modules loaded:
{"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","DevSettings","DevToolsSettingsManager","Networking","Appearance","DevLoadingView","HeadlessJsTaskSupport","UIManager","DeviceInfo","ImageLoader","SoundManager","IntentAndroid","DeviceEventManager","RNGestureHandlerModule","I18nManager","ReanimatedModule"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","LinkingManager","Worklets"]}

依赖配置

package.json 依赖项

"dependencies": {
    "metro-react-native-babel-preset": "^0.77.0",
    "react": "18.2.0",
    "react-native": "0.73.6",
    "react-native-gesture-handler": "^2.14.0",
    "react-native-reanimated": "^3.6.2",
    "react-native-svg": "^15.3.0",
    "react-native-vision-camera": "^4.0.5",
    "react-native-worklets-core": "^1.3.3"
  },

Android build.gradle 依赖配置

dependencies {
    implementation("com.facebook.react:react-android")
    implementation("com.facebook.react:react-native:+")
    implementation("com.facebook.soloader:soloader:0.10.3")
    implementation 'com.google.mlkit:pose-detection:18.0.0-beta4'
    implementation 'com.google.mlkit:pose-detection-accurate:18.0.0-beta4'
    implementation 'com.google.mlkit:vision-common:17.0.0'
    implementation 'com.google.mlkit:vision-interfaces:16.0.0'
    implementation 'com.google.mlkit:camera:16.0.0-beta3'
    implementation 'androidx.annotation:annotation:1.3.0'
    implementation 'com.google.android.gms:play-services-tasks:18.0.0'
    implementation 'com.android.support:multidex:1.0.3'


    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-vision-camera')
    implementation project(':react-native-svg')
    implementation project(':react-native-worklets-core')

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

Babel 配置

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    '@babel/plugin-proposal-class-properties',
    '@babel/plugin-transform-private-methods',
    '@babel/plugin-transform-flow-strip-types',
    '@babel/plugin-transform-runtime',
    '@babel/plugin-transform-arrow-functions',
    ['react-native-worklets-core/plugin'],
    ['react-native-reanimated/plugin', { globals: ['__poseDetection'] }],
  ],
};

已尝试的无效排查手段

  • 多次删除node_modules并重新安装依赖,错误依旧;
  • 尝试其他版本的vision-camera和worklets-core,除了vision-camera V4和worklets-core V1外,其他版本均与现有依赖存在兼容性问题,且同样报错;
  • 尝试手动将worklets-core链接到vision-camera,但1.x.x版本的worklets-core官方说明已自动链接,无需手动操作;
  • 将worklets-core改为peer dependency,导致Gradle构建失败,报错:
    > Could not resolve all task dependencies for configuration ':classpath'.
          > Could not find com.facebook.react:react-native-gradle-plugin:.
            Required by:
                project :
    
    改为标准依赖后Gradle可正常找到classpath;
  • 在settings.gradle中添加worklets-core的引用:
    include ':react-native-worklets-core'
    project(':react-native-worklets-core').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-worklets-core/android')
    
    无任何变化;
  • 在GitHub上查找类似问题,但未找到完全匹配的案例,现有解决方案均已尝试过。

疑问

是否遗漏了什么配置?有没有未注意到的缺失导入?

内容的提问来源于stack exchange,提问作者SetchFrank

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 03:53:13