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

React Native Release构建加载GLB模型崩溃但Debug模式正常的问题求助

React Native Release构建加载GLB模型崩溃但Debug模式正常的问题求助

大家好,我最近在开发一个基于Expo Modules的裸React Native项目,集成了expo-gl、react-three/fiber和react-three/drei来渲染带动画和外部JPG纹理的GLB模型。目前Debug模式下所有功能都正常运行,但打包成Release构建后,App一启动就直接崩溃了,实在找不到问题所在,想请各位帮忙分析一下。

报错信息

从adb logcat中捕获到的崩溃错误如下:

FATAL EXCEPTION: mqt_native_modules com.facebook.react.common.JavascriptException: Error: Could not load 36: undefined)

核心代码(App.js)

import React, { Suspense, useState } from 'react'
import {View} from 'react-native';
import { useFrame, Canvas } from '@react-three/fiber/native'
import { useGLTF, Environment, useAnimations, useTexture } from '@react-three/drei/native'
import stacy from './assets/stacy.glb';
import stacyTex from './assets/stacy.jpg';
import useControls from 'r3f-native-orbitcontrols'

function StacyModel({url, url1}, props) {
  const { nodes, animations } = useGLTF(url)
  const texture = useTexture(url1)
  const { ref, actions, names } = useAnimations(animations)
  const [index, setIndex] = useState(3)

  useFrame((state, delta) =>{
    actions[names[index]].play();
  })

  return (
    <group onClick={(event) => setIndex((index + 1) % names.length)} ref={ref} {...props} dispose={null}>
      <group rotation={[Math.PI / 2, 0, 0]} position={[0,-4,0]} scale={0.04}>
        <primitive object={nodes.mixamorigHips} />
        <skinnedMesh
          geometry={nodes.stacy.geometry}
          skeleton={nodes.stacy.skeleton}
          rotation={[-Math.PI / 2, 0, 0]}
          scale={100}>
          <meshStandardMaterial map={texture} map-flipY={false} skinning />
        </skinnedMesh>
      </group>
    </group>
  )
}

export default function App() {
  const[OrbitControls, events] = useControls();

  return (
    <View style={{flex: 1}} {...events}>
      <Canvas gl={{ physicallyCorrectLights: true }} camera={{ position: [0, 0, 16], fov: 50 }}
        onCreated={(state) => {
          const _gl = state.gl.getContext()
          const pixelStorei = _gl.pixelStorei.bind(_gl)
          _gl.pixelStorei = function(...args) {
            const [parameter] = args
            switch(parameter) {
              case _gl.UNPACK_FLIP_Y_WEBGL:
                return pixelStorei(...args)
            }
          }
        }}
      >
        <color attach="background" args={[0x000000]} />
        <directionalLight intensity={0.8} position={[-6, 2, 2]}/>
        <Suspense>
          <Environment preset="park" />
          <StacyModel url={stacy} url1={stacyTex} />
        </Suspense>
        <OrbitControls />
      </Canvas>
    </View>
  )
}

项目的build.gradle文件可以从我的GitHub仓库查看。

已尝试的解决方案

  • 手动捆绑资产资源
  • 在build.gradle中设置minifying-js: false

但以上操作都没能解决问题,Release构建依然会崩溃。希望有遇到过类似问题或者熟悉React Native + Three.js技术栈的朋友能帮忙指点一下,到底是什么原因导致的?有没有可行的修复方案?谢谢大家!

备注:内容来源于stack exchange,提问作者sedDev

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.23 13:17:48