[英]"react-native start" works, but crashes while "react-native run-android" is ongoing, even on a fresh project (bare workflow)
在 Android 上運行應用程序(由 Bare Workflow 中的“expo init appName”創建)需要首先react-native start
然后react-native run-android
。 會發生什么——
在第一個終端中,我運行react-native start
(從 VS Code 終端、普通終端嘗試過,這些終端也都作為管理員)。 它工作正常。
在第二個終端中,我運行react-native run-android
並且服務器崩潰(在第一個終端中)並且第二個終端可以顯示錯誤或顯示成功。
如果成功,則沒有用,因為服務器無法正常工作,因此會顯示該錯誤。
無法加載腳本。請確保您正在運行 Metro 服務器,或者您的捆綁包“index.android.bundle”已正確打包以供發布。
如果失敗,錯誤是(在第二個終端中,運行react-native run-android
的終端)
> Task :app:createDebugExpoConfig FAILED
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.8/userguide/command_line_interface.html#sec:command_line_warnings
30 actionable tasks: 2 executed, 28 up-to-date
internal/fs/utils.js:307
throw err;
^
Error: ENOENT: no such file or directory, open 'D:\bareWorkflowRN\tester1PaymentsNPlacePicker\android\app\build\generated\assets\expo-constants\debug\app.config'
at Object.openSync (fs.js:476:3)
at Object.writeFileSync (fs.js:1467:35)
at Object.<anonymous> (D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\expo-constants\scripts\getAppConfig.js:20:4)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'D:\\bareWorkflowRN\\tester1PaymentsNPlacePicker\\android\\app\\build\\generated\\assets\\expo-constants\\debug\\app.config'}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:createDebugExpoConfig'.
> Process 'command 'cmd'' finished with non-zero exit value 1
* 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
BUILD FAILED in 42s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
internal/fs/utils.js:307
並在第一個終端( react-native run
)
events.js:292
throw er; // Unhandled 'error' event
^
Error: EPERM: operation not permitted, lstat 'D:\bareWorkflowRN\tester1PaymentsNPlacePicker\android\app\build\generated\assets\expo-constants'
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.<anonymous> (D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\sane\src\node_watcher.js:291:16)
at FSReqCallback.oncomplete (fs.js:183:21) {
errno: -4048,
code: 'EPERM',
syscall: 'lstat',
path: 'D:\\bareWorkflowRN\\tester1PaymentsNPlacePicker\\android\\app\\build\\generated\\assets\\expo-constants'
顯示模塊名稱“expo-constants”的部分並不總是相同的。 它有時會有所不同,但錯誤的一般結構是這樣的。 例如
events.js:292
throw er; // Unhandled 'error' event
^
Error: EPERM: operation not permitted, lstat 'D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\expo-error-recovery\android\build\kotlin\compileDebugKotlin\caches-jvm\jvm'
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.<anonymous> (D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\sane\src\node_watcher.js:291:16)
at FSReqCallback.oncomplete (fs.js:183:21) {
errno: -4048,
code: 'EPERM',
syscall: 'lstat',
path: 'D:\\bareWorkflowRN\\tester1PaymentsNPlacePicker\\node_modules\\expo-error-recovery\\android\\build\\kotlin\\compileDebugKotlin\\caches-jvm\\jvm'
}
我試過(搜索網絡,尤其是 SO 帖子) -
a - 刪除 node_modules 和npm install
b- cd android
和gradlew clean
。 沒有影響。 在react-native run
之前以及在提到的兩個命令之間,我已經嘗試過這個。
在過去的 2-3 天里,我以各種排列方式嘗試了這些步驟,但這並不能解決問題。
我什至認為這可能是由於新的 expo 版本於 4 月 15 日推出,這可能會導致一些版本問題,所以我嘗試使用expo init appName
制作的新項目。 沒有對這個新應用程序進行任何更改,只是嘗試在模擬器上運行它。 它適用於expo start
但如果我嘗試react-native start
和react-native run-android
,同樣的問題會重復。
在這一點上,人們可能會注意到,這個問題本質上可以稱為循環
另外,這樣做有意義嗎 -
react-native start
react-native run-android
,讓服務器崩潰並讓應用程序安裝錯誤 - “無法加載腳本。確保您正在運行 Metro 服務器或您的捆綁包 'index.android.bundle' 已正確打包以供發布。 "react-native start
。我認為(不確定)稍后啟動服務器沒有意義,但在我的許多努力下,這隨機工作了兩次。 無法復制。
我的系統Windows 10這是我的 package.json (它是用新的應用程序生成的,沒有改動)
{
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"expo": "~41.0.0",
"expo-splash-screen": "~0.10.2",
"expo-status-bar": "~1.0.4",
"expo-updates": "~0.5.4",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.63.4",
"react-native-gesture-handler": "~1.10.2",
"react-native-reanimated": "~2.1.0",
"react-native-screens": "~3.0.0",
"react-native-unimodules": "~0.13.3",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"babel-jest": "~25.2.6",
"jest": "~25.2.6",
"react-test-renderer": "~16.13.1"
},
"jest": {
"preset": "react-native"
},
"private": true
}
高度贊賞任何幫助。 讓我知道是否需要更多信息
expo 41 彈出后也存在同樣的問題。
通過查看“沒有這樣的文件或目錄... android\app\build\generated\assets\expo-constants\debug\app.config” output 我通過在 android\app\build 內手動創建目錄 debug 來解決\生成\資產\博覽會常數。
並且后續紗線android成功。
注意:如果紗線 android 崩潰,應重新創建調試目錄。
PS: https://github.com/expo/expo-cli/blob/master/packages/config/src/Config.ts目前正在修改中。 所以我希望這個bug能盡快修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.