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

切换到Expo模块后,裸工作流React Native Expo项目构建失败

React Native Expo裸工作流Android构建错误求助

迁移Expo项目到裸工作流后,执行npx expo run:android向Android设备安装应用时触发构建错误,核心报错为:expo-modules-core:configureCMakeDebug[arm64-v8a]任务执行失败,提示无法找到或加载主类com.google.prefab.cli.AppKt,同时伴随Gradle守护进程异常、Kotlin插件重复加载的警告。已查阅官方文档并尝试GitHub相关issue方案,问题未解决。

环境信息

  • 操作系统:Windows 11

项目依赖

"dependencies": {
    "@gorhom/bottom-sheet": "^4.6.0",
    "@hookform/resolvers": "^3.3.4",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-firebase/app": "^18.8.0",
    "@react-native-masked-view/masked-view": "0.2.9",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/drawer": "^6.6.6",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/stack": "^6.3.20",
    "@tanstack/react-query": "^5.17.15",
    "@types/react": "~18.2.14",
    "axios": "^1.6.1",
    "expo": "~49.0.15",
    "expo-build-properties": "~0.8.3",
    "expo-camera": "~13.4.4",
    "expo-clipboard": "~4.3.1",
    "expo-dev-client": "~2.4.12",
    "expo-document-picker": "~11.5.4",
    "expo-file-system": "~15.4.5",
    "expo-image-picker": "~14.3.2",
    "expo-media-library": "~15.4.1",
    "expo-permissions": "~14.2.1",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "prop-types": "^15.8.1",
    "react": "18.2.0",
    "react-hook-form": "^7.49.2",
    "react-native": "0.72.6",
    "react-native-app-intro-slider": "^4.0.4",
    "react-native-element-dropdown": "^2.10.1",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-masked-text": "^1.13.0",
    "react-native-reanimated": "~3.3.0",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-toast-message": "^2.2.0",
    "react-native-vector-icons": "^10.0.3",
    "styled-components": "^6.1.7",
    "yup": "^1.3.3"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "eslint": "^8.56.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-jsx-a11y": "^6.8.0",
    "eslint-plugin-prettier": "^5.1.2",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-native": "^4.1.0",
    "prettier": "^3.1.1"
  }

可尝试的解决方案

  • 清理Gradle缓存:执行gradlew clean(Windows环境),删除项目根目录的.gradle文件夹和android/.gradle文件夹,重新执行构建命令。
  • 统一Kotlin版本:在android/build.gradle中指定统一的Kotlin版本,比如ext.kotlin_version = "1.9.0"(匹配React Native 0.72.x的推荐版本),确保所有模块使用相同版本。
  • 检查仓库配置:在android/build.gradle的buildscript和allprojects区块中,确保添加Google Maven仓库:
    repositories {
        google()
        mavenCentral()
    }
    
  • 更新Expo Modules Core:执行npm install expo-modules-core@latest,升级到匹配Expo 49的最新版本。
  • 验证Java版本:确保使用Java 17(React Native 0.72.x官方推荐版本),避免版本不兼容导致类加载失败。
  • 临时禁用Gradle守护进程:执行npx expo run:android --no-daemon,跳过守护进程构建排查问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 02:57:05