Android ARM 设备/模拟器上的 libusb 崩溃
我正在使用 NDK 来编译 libusb(均来自以下位置提供的预构建版本: https://github.com /monaka/libusb-android)以及使用他的更改来编译最新的可用版本(libusb-1.0.8)。它似乎已加载,并且对“init()”的初始调用不会返回错误。但是,当我尝试对库进行基本调用以列出设备(来自 libusb 中包含的示例 lsusb 代码)时,我遇到了崩溃。使用 NDK 提供的“arm-eabi-addr2line”和转储提供的地址作为错误,我追踪到 libusb 中的设备列表方法从它找到的设备中获取“未知状态”导致调用“usbi_log()”方法并发生崩溃。 NDK 工具不提供行号,因此这就是我所掌握的发生错误的位置的所有详细信息。
libusb 源代码库: http://git.libusb.org/ ?p=libusb.git;a=summary;js=1
我正在通过一个极其简单的操作对 libusb 进行简单的 JNI 调用,尽管我没有任何理由认为这是问题的一部分。它是一个非常基本的 .h(来自 javah)文件和 .c 文件,它复制提供的“lsubs”示例程序的操作,并且 Action 类除了在 onLoad() 方法中进行调用之外什么也不做。
在模拟器中运行时我也会崩溃。还拔掉设备(Nexus One)以禁用调试(也在设备上的“应用程序”->“开发”中禁用)并使 USB 总线(理论上)为空(至少是外部物理设备)并发生相同的崩溃。
设备和模拟器 Android 版本:2.2
NDK版本:r5b
ADK版本:r10
主机操作系统:OSX
感谢您提供的任何帮助!
I'm using the NDK to compile libusb (both from the prebuilt one supplied at: https://github.com/monaka/libusb-android) as well as using his changes to compile the latest available (libusb-1.0.8). It appears to load and the initial call to "init()" does not return an error. However, when I try to make the basic call into the library to list devices (from the sample lsusb code included in libusb) I get a crash. Using the NDK-provided "arm-eabi-addr2line" and the address which the dump provides as the fault, I've tracked it down to being that the device listing method in libusb gets an "unknown status" from the device it finds which causes the "usbi_log()" method to be called within which the crash occurs. The NDK tools don't give me line numbers so that's all the details I have for where the error is occurring.
libusb source repo: http://git.libusb.org/?p=libusb.git;a=summary;js=1
I am making a simple JNI call into libusb from a dead-simple Action, though I don't have any reason to think this is part of the issue. It is a very basic .h (from javah) file and .c file which copies the action of the provided "lsubs" sample program and the Action class does nothing but make the call in the onLoad() method.
I also get a crash when running in the emulator. Also unplugged device (a Nexus One) to disable debugging (also disabled in Applications->Development on device) and to have USB bus (theoretically) empty (of at least external physical devices) and get same crash.
Device and emulator Android version: 2.2
NDK version: r5b
ADK version: r10
Host OS: OSX
Thank you for any help you can provide!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在手机上安装了 ssh 守护进程,那么您可以使用端口转发 ssh 进入它并运行 gdbserver 并从 PC 上的 gdb 连接到该守护进程。
您可能需要先构建一个命令行可执行测试,然后再将其连接到您的 java 应用程序。
If you install an ssh daemon on the phone, then you can ssh into it with port forwarding and run gdbserver and connect to that from gdb on the pc.
You may want to build a command line executable test first, before hooking it up to your java app.