gpt4 book ai didi

Ubuntu 上的安卓模拟器

转载 作者:太空宇宙 更新时间:2023-11-03 17:06:34 25 4
gpt4 key购买 nike

我想使用 Ubuntu 16.04 在 Android 模拟器上启动 React Native 应用程序。按照 native react 文档,它应该通过运行来完成

react-native run-android

npm run android

出于某种原因,如果没有 sudo,这两个命令都无法正常工作,但这不是问题。问题是当我每次遇到相同的错误时运行它们:

Error running adb: No Android device found. Please connect a device and follow the instructions here to enable USB debugging: https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select "Use custom Android SDK tools", and point it at your Android SDK directory.

enter image description here

我不想通过 USB 连接设备,也不使用 Genymotion,我只想要一个模拟器。我尝试通过 Android Studio 运行该项目,但遇到了另一个问题:

Error: please select Android SDK

enter image description here

我试过同步文件、删除项目、重启工作室——什么都没有。 (但是我可以在设备列表中看到 Nexus 5X,甚至可以启动它)请有人帮助我,我已经尝试了我能找到的一切 - 没有任何帮助

最佳答案

Both these commands are not working without sudo for some reason, but that's not an issue.

这可能是根本原因。

因为,如果您曾经使用“sudo”安装过您的 Android SDK/工具,或者您将其安装到 root 用户的目录中,那么普通帐户可能无法访问或执行这些文件。因此,请尝试以下步骤:

  1. 删除隐藏目录 ~/.gradle ~/.idea ~/.m2~/.android 使用命令

    sudo rm -rf ~/.gradle ~/.idea ~/.m2 ~/.android

    这一步是为了清除您之前安装的具有root权限的文件。如果您没有这些文件夹,请忽略此步骤。

  2. 将您的 Android Studio 重新安装到您的普通用户主目录中,例如~/android

  3. 使用新安装的 Android Studio 创建您的 AVD。

不要为您新配置的环境使用任何“sudo”。因为任何以 root 权限安装的东西都将转到根目录,即 /,而不是您的普通用户主目录,即 ~/。如果您以普通用户启动您的 Android Studio,通常它只能引用您在 ~/ 下的设置。这可能是无法找到您“已安装”的 Android SDK 的原因。

关于Ubuntu 上的安卓模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51363770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com