通过 adb 访问 shell

您可以将您的 UBports 设备置于开发者模式并从 PC 访问 Bash Shell。这对调试和高级使用非常有帮助。

安装 ADB

首先,您需要在您的计算机上安装 ADB。

在 Ubuntu 上:

sudo apt install android-tools-adb

在 Fedora 上:

sudo dnf install android-tools

在 MacOS 上使用 Homebrew:

brew install android-platform-tools

对于 Windows,从`这里 <https://developer.android.com/studio/index.html#downloads>`_ 获取命令行工具包。

启用开发者模式

接下来,您需要启用开发者模式。

  1. 重启你的设备
  2. 将您的设备置于开发者模式(设置 - 关于 - 开发者模式 - 选中此框将其打开)
  3. 将设备插入已安装 adb 的计算机上
  4. 打开终端,运行 adb devices

注解

当您使用完 shell 之后,最好关闭开发者模式。

如果列表中有设备(该命令不显示 “List of devices attached” 和空行),则说明可以使用 ADB 。若没有,请读下面。

添加硬件 ID

ADB doesn’t always know what devices on your computer it should or should not talk to. You can manually add the devices that it does not know how to talk to.

Just run the command for your selected device if it’s below. Then, run adb kill-server followed by the command you were initially trying to run.

Fairphone 2:

printf "0x2ae5 \n" >> ~/.android/adb_usb.ini

Oneplus One:

printf "0x9d17 \n" >> ~/.android/adb_usb.ini