expo运行android studio,Major issues trying to run react native, expo, vs code, android studio

博主在尝试使用React-Native、VSCode、Expo和Android Studio搭建并运行Hello World应用时遇到一系列问题,包括adb连接失败、虚拟设备崩溃、开发者菜单无法打开、Chrome调试器匹配错误等。尝试了多种解决方案但收效甚微,感到极度困扰。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I am brand new to React-Native and have been consistently having major issues getting things up and running. I am using VS Code, Expo, Chrome, and Android Studio. I have encountered at least a dozen major issues trying to get a simple "Hello World" app running and none of the solutions to the particular problems has really worked leading me to believe there is a bigger issue going on. I'll try to run through a few of the issues I've had so far but as I said I'm totally new to this so I can't really understand/remember every issue that has come up.

I have consistently had issues getting metro bundler/expo and the Android Virtual Devices connecting. Sometimes they work, but most of the time I get the warning message "Couldn't adb reverse: device 'adb' not found" followed by the error message "Couldn't start project on Android: Error running adb: device 'adb' not found." If the device does work, if I try to reload from the developer menu or debug from the developer menu, expo crashes on the virtual device. Often I get a blank white screen and the developer menu will no longer open. I've had occasional success stopping the virtual device, restarting it, closing all expo windows, and trying to "run on android" from metro bundler. When this doesn't work, I've tried wiping the virtual device. Sometimes this works. Most often I have to delete the device and create a new one.

When I tried to run the debugger in Chrome, the times it appeared to work, I got console screens that didn't match any guides I've found online. Trying to force errors to understand the Chrome debugger completely crashed the virtual device. Had to close VS Code, Chrome, and delete the virtual device to be able to even begin again.

When I tried to follow guides to debug in VS Code I couldn't get that to work either. Regardless if I put in break points or not when I tried to run "attach to packager" it wouldn't output anything but I could hear my machine running really hard and VS Code seemed like it was trying to do something. I would have to close VS Code to get it working again. The other issue I would get an error telling me that Packager was running outside of VS Code. I would try to close down Android Studio and restart and I would get the same error. One time I almost got it working but the virtual device completely crashed and started flashing a white screen and had to be deleted.

I've had tons of other random errors that have only happened once or twice including some warning message about the binary of the android devices being obsolete or something like that.

Anyone have any idea what could be causing all of this? I've been dealing with this for almost two weeks and it has become incredibly frustrating.

### Android Studio 同步问题及其解决方案 在开发过程中,Android Studio 的同步问题是开发者经常遇到的情况之一。以下是可能导致同步失败的原因以及相应的解决方法。 #### 1. 构建文件中的包名不匹配 如果项目的 `build.gradle` 文件、清单文件 (`manifest`) 或 XML 资源文件中定义的包名与其他地方存在差异,则可能会导致同步错误。在这种情况下,建议仔细检查并修改这些位置中的包名以保持一致性[^1]。完成更改后,执行 **Sync Project with Gradle Files** 操作来验证配置是否正确。 #### 2. 缓存问题 有时缓存可能引起冲突或数据损坏,从而阻止项目成功构建。可以尝试清理和重建项目 (Clean/Rebuild),或者通过以下命令清除缓存: ```bash ./gradlew cleanBuildCache ``` 此操作会删除旧有的编译产物,并重新生成新的依赖关系树。 #### 3. 隐藏文件夹命名约定 对于版本控制系统(如 SVN),某些隐藏目录(例如 `.svn`)的存在也可能干扰集成环境的行为模式。由于 Microsoft Visual Studio 对于开头带有句号的文件夹处理不当,因此推荐改用 `_svn` 前缀替代默认设置[^2]。即使当前使用的不是 VS 平台,在跨团队协作场景下也应遵循这一最佳实践以免后续迁移工具链时遭遇兼容性障碍。 #### 4. 插件更新状态 确保所安装的所有插件均为最新版;过期版本可能存在 bug 导致异常行为发生。前往菜单栏路径 Tools -> SDK Manager 来确认 Android SDK 及其关联组件处于最前沿水平的同时也要留意官方文档公告是否有针对性修复措施发布。 最后提醒一点就是当以上常规手段均无法奏效之时不妨考虑重置整个工作区至初始提交记录点再逐步恢复改动直至定位确切诱因所在为止。 ```python # Example of resetting git repository to initial commit import subprocess def reset_to_initial_commit(repo_path): try: result = subprocess.run(['git', 'rev-list', '--max-parents=0', 'HEAD'], cwd=repo_path, capture_output=True, text=True) first_commit_hash = result.stdout.strip() # Reset hard will discard all changes since the specified hash. subprocess.run(['git', 'reset', '--hard', first_commit_hash], cwd=repo_path) except Exception as e: print(f"Error occurred while trying to reset repo: {e}") # Usage example reset_to_initial_commit('/path/to/android/project') ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值