[英]fix Android Studio React-Native WSL won't launch emulator with more errors
I'm new to android studio.我是 android 工作室的新手。 I downloaded Bumblebee and then followed the react-native quick start installation guide react-native installation我下载了 Bumblebee 然后按照 react-native 快速入门安装指南react-native 安装
I will open Android studio and within the terminal run npx react-native init MyApp, cd MyApp, npx react-native start, npx react-native run-android.我将打开 Android 工作室并在终端中运行 npx react-native init MyApp, cd MyApp, npx react-native start, npx ZB0DF5BC3BAE30D491ZB0DF5BC3BAE30D4911 run I get the errors:我得到错误:
error Failed to launch emulator. Reason: No emulators found as an output of 'emulator -list-avds'
Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated.
6 actionable tasks: 4 executed, 2 up-to-date
Note: /mnt/c/Users/RandallTaylor/Mobile/App3/node_modu
* What went wrong:
Could not determine the dependencies of task ":app:compileDebugJavaWithJavac".
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at "/mnt/c/Users/RandallTaylor/Mobile/App3/android/local.properties"
/ note local.properties exists. I attempted with the linux and windows path version as SDK manager points to the Microsoft OS where it exits. and still get this error /
I've spent two days on this reading stack overflow thread with no progress.我在这个阅读堆栈溢出线程上花了两天时间,没有任何进展。 Any advice would be appreciated.任何意见,将不胜感激。
SetUp and local system info:设置和本地系统信息:
Windows 10 Windows 10
Processor AMD Ryzen 7 PRO 5850U处理器 AMD 锐龙 7 PRO 5850U
wsl --status Default Distribution: Ubuntu-20.04 Default Version: 2 wsl --status 默认发行版:Ubuntu-20.04 默认版本:2
Windows Subsystem for Linux was last updated on 4/27/2022 WSL automatic updates are on. Linux 的 Windows 子系统上次更新时间为 2022 年 4 月 27 日 WSL 自动更新已开启。
Kernel version: 5.10.102.1 Kernel 版本:5.10.102.1
Android Studio Bubblebee Android Studio Bubblebee
SDK manager -> SDK Platorms -> Android 11.0R with Android SDK Platform 30, Source for Android 30, Intel x86 Aton Sytem Image SDK Tools -> 30.0.2 installed SDK manager -> SDK Platorms -> Android 11.0R with Android SDK Platform 30, Source for Android 30, Intel x86 Aton Sytem Image SDK Tools -> 30.0.2 installed
Environment Variables -> ANDROID_HOME C:\Users\UserName\AppData\Local\Android\Sdk ANDROID_ROOT same as ANDROID_HOME JAVA_HOME C\Users\UserName\Desktop环境变量 -> ANDROID_HOME C:\Users\UserName\AppData\Local\Android\Sdk ANDROID_ROOT 与 ANDROID_HOME JAVA_HOME C\Users\UserName\Desktop 相同
cmdline-tools\external\com\google\guava\guava\30.1-jre cmdline-tools\external\com\google\guava\guava\30.1-jre
You need to install on your Windows 10 Android Studio.您需要在 Windows 10 Android Studio 上安装。
Set user variable: ANDROID_HOME=C:\Users<YOUR_USER>\AppData\Local\Android\Sdk设置用户变量:ANDROID_HOME=C:\Users<YOUR_USER>\AppData\Local\Android\Sdk
Add to system variable PATH:添加到系统变量PATH:
Then go to your WSL2 and install:然后 go 到您的 WSL2 并安装:
sudo apt-get install unzip
sudo apt-get install openjdk-8-jdk
使用sudo apt-get install openjdk-8-jdk
安装 jdk 8export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
export ADB_SERVER_SOCKET=tcp:$WSL_HOST:5037
export ANDROID_HOME=$HOME/Android
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
sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
重启 bash 并运行sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
adb version && adb.exe version
check if versions match运行adb version && adb.exe version
检查版本是否匹配Running on emulator在模拟器上运行
emulator -avd <YOUR_AVD_NAME>
- don't close terminal window启动模拟器运行emulator -avd <YOUR_AVD_NAME>
- 不要关闭终端 windowadb kill-server
and adb -a -P 5037 nodaemon server start
- don't close terminal window运行adb kill-server
和adb -a -P 5037 nodaemon server start
- 不要关闭终端 windowadb devices
and check you device port, eg device port is 5554.运行adb devices
并检查您的设备端口,例如设备端口是 5554。socat -d -d TCP-LISTEN:5554,reuseaddr,fork TCP:$(cat /etc/resolv.conf | tail -n1 | cut -d " " -f 2):5554
, to install socat sudo apt-get install socat
,形成你的wsl终端运行socat -d -d TCP-LISTEN:5554,reuseaddr,fork TCP:$(cat /etc/resolv.conf | tail -n1 | cut -d " " -f 2):5554
,安装socat sudo apt-get install socat
,yarn start
inside project folder and then click 'a' to run android emulator, it takes me about 4-5 minutes.在项目文件夹中运行yarn start
然后单击“a”运行 android 仿真器,大约需要 4-5 分钟。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.