简体   繁体   English

Qt Creator和Android在模拟器上运行,但在硬件设备上崩溃

[英]Qt Creator and Android Run on emulator but crash on hardware device

I'm having a hard time to have the debugger running on an external device. 我很难让调试器在外部设备上运行。

Using - the latest Qt Creator and Qt framework 5.9.2 - Android SDK & NDK installed with the Android Studio - Java jdk1.8.0_152 - Android API 26 - Win 10. 使用-最新的Qt Creator和Qt框架5.9.2-随Android Studio安装的Android SDK和NDK-Java jdk1.8.0_152-Android API 26-Win 10。

I can build and run the app in debug on a x86 Android emulator successfully. 我可以在x86 Android模拟器上的调试中成功构建并运行该应用程序。

I can successfully build for amd but when I try to run in debug my external device, it crashes right away and fails to connect to the debugger with the message " Failed to contact debugging port ." 我可以为amd成功构建,但是当我尝试在调试外部设备中运行时,它立即崩溃并且无法通过消息无法联系调试端口连接到调试器

The app crash at start if manually started. 如果手动启动,则应用程序在启动时崩溃。

The USB debug is enabled on the phone. 手机已启用USB调试。

Is there any additional configuration required? 是否需要其他配置?

Finally after much digging. 最后经过多方挖掘。

The compiler used with QtCreator generates armeabi-v7a lib files. 与QtCreator一起使用的编译器生成armeabi-v7a lib文件。

Those files are included into the /libs/ folder on the apk. 这些文件包含在apk的/ libs /文件夹中。

Our project required to use some other external libs that were also compiled for other architectures. 我们的项目需要使用其他一些外部库,这些库也已针对其他体系结构进行了编译。 The folder /libs/ of the generated apk contained libs for those different architecture, but the main project was available only for the armeabi-v7a. 生成的apk的文件夹/ libs /包含用于这些不同体系结构的lib,但是主项目仅可用于armeabi-v7a。

Therefore the app would be started and try to find the lib to the preferred architecture and would crash right away. 因此,该应用程序将启动并尝试找到首选架构的库,并且立即崩溃。

The solution is to force using only the available architecture. 解决方案是仅使用可用的体系结构。

This is done by adding this to the build.gradle script 这可以通过将其添加到build.gradle脚本中来完成

 defaultConfig {
    ndk {
        abiFilters  'armeabi-v7a'
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM