Ubuntu 上的安卓模拟器

标签 android android-studio ubuntu react-native

我想使用 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/

相关文章:

php - 入门主题 Prestashop 1.7 为空白

android - 以下类无法实例化 : - com. google.ads.AdView Admob

android - 解析推送通知异常: "unauthorized: master key is required"

android - android studio 中的 Kotlin 插件错误

将输出格式设置为 "table"(.mode 表)时出现 SQLite3 错误

ubuntu - ubuntu xenial、yakety 和 zesty 之间的区别

java - 导航回 FragmentPagerAdapter,listFragment 为空

java - 适配器 ListView 中的 onTouchListener 使 onItemClickListener 未运行

android - 使用 C++ 支持创建 Android 项目的正确方法

android studio Logcat在单行和部分数据中显示json数据