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

Expo SDK升级至48/49后React Native Android应用异常求助

问题描述
  • 背景:为适配Android Target SDK API Level 33,将Expo SDK升级至48后,仅Android Release环境调用Expo Image Picker、Expo Document Picker相关函数时出现错误,iOS及Android开发、预发布环境均正常。
  • 触发错误的函数:
    ImagePicker.launchImageLibraryAsync()
    ImagePicker.launchCameraAsync()
    DocumentPicker.getDocumentAsync()
    
  • 错误提示:函数调用被拒绝,参数无法转换为特定类型,伴随异常:
    java.lang.IllegalArgumentException: Cannot convert js value to enum without the primary constructor
    
升级至Expo SDK 49后的情况

当前开发环境信息

expo-env-info 1.0.5 environment info:
  System:
    OS: macOS 13.5.2
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10671973
    Xcode: 15.0/15A240d - /usr/bin/xcodebuild
  npmPackages:
    expo: ^49.0.11 => 49.0.11
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    react-native: 0.72.4 => 0.72.4
    react-native-web: ~0.19.6 => 0.19.9
  Expo Workflow: bare

  Additional Android Related Info:
    Gradle: 7.6.2
    Android Gradle Plugin: 7.4.2
    Gradle JDK: 17.0.6

新出现的异常

升级至SDK 49后原问题未解决,反而出现Expo FileSystem模块异常,应用启动后卡在加载状态,错误信息:

{
    [
        Error: Call to function 'ExponentFileSystem.downloadAsync' has been rejected.
        Caused by: The 3rd argument cannot be cast to type expo.modules.filesystem.DownloadOptions (received Map)
        Caused by: Cannot create a record of the type: 'expo.modules.filesystem.DownloadOptions'.
        Caused by: java.lang.IllegalArgumentException: Cannot convert js value to enum without the primary constructor
    ]
    code: 'ERR_UNEXPECTED',
    line: 86,
    column: 349,
    sourceURL: 'index.android.bundle'
}
已尝试的无效方案
  • 升级Gradle和Android Gradle Plugin至8.0.x
  • 降级Gradle JDK至11

求提供技术帮助与解决方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 23:12:06