本页内容

在安卓设备上调试

您可以使用 LLDB 在使用 Qt 5.15.9 或更高版本和 Qt 6.2 或更高版本开发的 Android 设备上调试应用程序。

最近发布的Qt Creator 有在 Android 上使用 LLDB 进行本地(C++)调试的问题。

Qt Creator 17.0.1 已修复了这一问题。要修复早期版本中的问题,请访问Preferences >Debugger >GDB ,并在Additional Attach Commands 中添加以下内容。

settings set plugin.jit-loader.gdb.enable off

调试器首选项中的 GDB 选项卡

在设备上启用调试

在不同的 Android 设备上启用调试的方式不同。在Developer Options 下查找USB Debugging 。在Settings >About 中多次点击Build number ,显示Developer Options

选择调试构建配置

转到Projects >Build Settings ,在Active build configuration 中选择调试构建配置,以构建用于调试的应用程序。

解决与第二个调试器的冲突

Qt Creator 如果 Android Studio 正在运行,则无法调试 Android 设备上的应用程序。如果应用程序输出中出现以下消息,请关闭 Android Studio 并重试:

Ignoring second debugger -accepting and dropping.

使用 Android 仿真器

要在 Linux、macOS 或 Windows 上模拟 Android 设备,请使用 Android 模拟器。Android 模拟器在称为 Android 虚拟设备 (AVD) 的虚拟机中运行 Android 操作系统。

另请参阅 如何:为 Android 开发为 Android 开发配置设备上的开发人员选项

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.