尝试使用 expo run:android React Native Expo 时出错并失败

Error And Failed When Try To Use expo run:android React Native Expo

谁能知道为什么我使用 expo run:android 构建时失败了?

This the detail error :

> Configure project :expo-file-system
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.

> Configure project :expo-structured-headers
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

> Configure project :expo

Using expo modules
  - expo-application (4.0.2)
  - expo-constants (13.0.2)
  - expo-crypto (10.1.2)
  - expo-error-recovery (3.0.5)
  - expo-file-system (13.1.4)
  - expo-font (10.0.5)
  - expo-json-utils (0.2.1)
  - expo-keep-awake (10.0.2)
  - expo-manifests (0.2.4)
  - expo-modules-core (0.6.5)
  - expo-screen-orientation (4.1.2)
  - expo-sharing (10.1.1)
  - expo-splash-screen (0.14.2)
  - expo-sqlite (10.1.1)
  - expo-structured-headers (2.1.1)
  - expo-updates (0.11.6)
  - expo-web-browser (10.1.1)


> Configure project :react-native-reanimated
AAR for react-native-reanimated has been found
E:\Application\daastradingapp\node_modules\react-native-reanimated\android\react-native-reanimated-64-jsc.aar

> Task :react-native-reanimated:replaceSoTaskDebug FAILED

FAILURE: Build failed with an exception.

* Where:
Build file 'E:\Application\daastradingapp\node_modules\react-native-reanimated\android\build.gradle' line: 122

* What went wrong:
Execution failed for task ':react-native-reanimated:replaceSoTaskDebug'.
> Warning: Could not find file E:\Application\daastradingapp\android\app\build\tmp\libSo\jni\x86\libfbjni.so to copy.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 51s
569 actionable tasks: 6 executed, 563 up-to-date
E:\Application\daastradingapp\android\gradlew.bat exited with non-zero code: 1
Error: E:\Application\daastradingapp\android\gradlew.bat exited with non-zero code: 1
    at ChildProcess.completionListener (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:65:13)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at ChildProcess.cp.emit (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (internal/child_process.js:1055:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    ...
    at spawnAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
    at spawnGradleAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:83:18)
    at assembleAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:57:16)
    at actionAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\runAndroid.ts:143:9)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

注:

我用的是expo bare worfklow

终于解决了问题

Expo 中,如果使用原生模块,我们不能在 Expo Go.

中 运行

如果我们想使用 Native Module

发布到 Expo Dashboard

使用EAS 构建

示例:

运行 eas build --platform android 为 Android.

构建

运行 eas build --platform ios 为 iOS.

构建

或者,您可以 运行 eas build --platform all 同时为 Android 和 iOS 构建。

完整的文档可以在这里找到:

EAS Documentation Expo