gri*_*ode 5 android gradle android-emulator react-native expo
在 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
Run Code Online (Sandbox Code Playgroud)
在第一个航站楼 ( 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'
Run Code Online (Sandbox Code Playgroud)
显示模块名称“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'
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过(搜索网络,尤其是SO帖子)-
a - 删除node_modules和npm install
乐队。cd android
gradlew clean
没有影响。我之前已经尝试过react-native run
,并且也在提到的两个命令之间尝试过。
在过去的 2-3 天里,我已经尝试了各种排列的这些步骤,但这并不能解决问题。
我什至认为这可能是由于 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
}
Run Code Online (Sandbox Code Playgroud)
任何协助都高度赞赏。如果需要更多信息,请告诉我
小智 3
41 届世博会弹出后也存在同样的问题。
通过查看“没有这样的文件或目录... android\app\build\ generated\assets\expo-constants\debug\app.config”输出,我通过在 android\app\build 内部手动创建目录 debug 来解决此问题\ generated \ assets \ expo-constants。
并且下面的yarn android 成功了。
注意:如果yarn android崩溃,应该再次重新创建调试目录。
PS:https: //github.com/expo/expo-cli/blob/master/packages/config/src/Config.ts目前正在修改。所以我希望这个错误能够尽快得到修复。
归档时间: |
|
查看次数: |
3527 次 |
最近记录: |