问题描述
我基于这个答案:https://stackoverflow.com/a/58229368/13495096>
我需要通过 WSL2 在 Windows 中使用 react-native
进行开发.
我完全按照答案进行了操作,并在解决了几个小时的错误后,得出了以下结论:
- WSL2 已安装并正在运行 (Ubuntu 20.04 LTS)
- Android Studio 安装在 Windows 10 (Pro x64) 上;
- ADB 在 WSL2 和 Windows (1.0.32) 中的版本相同;
- $PATH 在我的 .zshrc 文件中正确配置(如下):
# Android SDK导出 JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/导出 ANDROID_SDK_ROOT=/usr/lib/android-sdk导出 ANDROID_HOME=/Android/Sdk导出路径=$PATH:$ANDROID_HOME/模拟器导出路径=$PATH:$ANDROID_HOME/工具导出路径=$PATH:$ANDROID_HOME/tools/bin导出路径=$PATH:$ANDROID_HOME/platform-tools导出路径=$PATH:$JAVA_HOME/bin导出路径=$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$PATH
我在 Android Studio (Windows) 和 Powershell 上启动了一个设备,当运行 adb devices
时,它返回:
连接的设备列表模拟器-5554 设备
当我在 WSL 终端上运行 adb devices
时,它只返回连接的设备列表
,没有其他任何东西.
根据链接的答案,可以做到,但我做不到.我怎样才能做到这一点?我错过了什么?
我正在从 OS X 迁移到 Windows,我从未尝试过 Linux.
最终找到了解决我问题的教程(但提出了一些其他问题,例如无法从 Android Emulator 访问 localhost)
https://gist.github.com/bergmannjg/461958db03c6ae41a66d264ae6504ade
I'm based on this answer: https://stackoverflow.com/a/58229368/13495096
I need to develop using react-native
in Windows through WSL2.
I did exactly what the answer says and after a few hours of solving some errors, got to the point where:
- WSL2 is installed and running (Ubuntu 20.04 LTS)
- Android Studio is installed on Windows 10 (Pro x64);
- ADB is with the same version in both WSL2 and Windows (1.0.32);
- $PATH is configured properly (below) in my .zshrc file:
# Android SDK
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
export ANDROID_HOME=/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$PATH
I start a device on Android Studio (Windows) and in Powershell, when running adb devices
, it returns:
List of devices attached
emulator-5554 device
When I run adb devices
on my WSL terminal, it returns only List of devices attached
, with nothing else.
Based on the linked answer, it's possible to do it but I can't. How can I make that happen? What am I missing?
I'm moving from OS X to Windows and I never tried Linux.
Ended up finding this tutorial that solved my problem (but raised some others, like not being able to access localhost from Android Emulator)
https://gist.github.com/bergmannjg/461958db03c6ae41a66d264ae6504ade
这篇关于将 WSL2 与 zsh 一起使用时,如何在 Windows 上运行 Android 模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!