简体   繁体   English

使用Qt Creator为Android构建Qt应用程序时出错

[英]Error building Qt app for Android with Qt Creator

When I tried to build QtFireExample with my QtCreator, failed with below error message. 当我尝试使用我的QtCreator构建QtFireExample时,失败并显示以下错误消息。

The installed SDK tools version (26.1.1) does not include Gradle scripts. 已安装的SDK工具版本(26.1.1)不包含Gradle脚本。 The minimum Qt version required for Gradle build to work is 5.9.0/5.6.3 Error while building/deploying project QtFirebaseExample (kit: Android) When executing step "Build Android APK" Gradle构建工作所需的最低Qt版本是5.9.0 / 5.6.3构建/部署项目时出错QtFirebaseExample(kit:Android)执行步骤“构建Android APK”时

My android studio is 3.2.1. 我的android工作室是3.2.1。 And SDK tools 26.1 is also installed. 还安装了SDK工具26.1。
qt version is also above 5.9.0 qt版本也高于5.9.0
What I did mistake? 我做错了什么?

❯ qmake --version
QMake version 3.1
Using Qt version 5.12.0 in /usr/local/Cellar/qt/5.12.0/lib

There's more steps to follow before you can deploy your first Android app using QtCreator. 在使用QtCreator部署第一个Android应用程序之前,需要遵循更多步骤。 Installing SDK tools is not enough. 安装SDK工具是不够的。 Here is what I did, I'm using Windows, but hopefully the steps are the same under Ubuntu. 这是我做的,我正在使用Windows,但希望Ubuntu下的步骤是一样的。

  • Install QtCreator using the link provided by Hitokage, include QtCreator (I got version 4.8.0), and Qt 5.12.0 binaries for your platform + needed Android (armv7, x86...) 使用Hitokage提供的链接安装QtCreator,包括QtCreator(我的版本为4.8.0),以及适用于您平台的Qt 5.12.0二进制文件+所需的Android(armv7,x86 ......)
  • Get JDK 1.8.XX 获得JDK 1.8.XX
  • Get NDK r18b (or a more recent version) 获取NDK r18b(或更新版本)
  • Get SDK tools 26.1.1 (what you already did) 获取SDK工具26.1.1(你已经做过的)
  • SDK tools itself is not enough, some SDK modules must be installed, from SDK tools folder, run: SDK工具本身还不够,必须安装一些SDK模块,从SDK工具文件夹中运行:
    • sdkmanager platform-tools
    • sdkmanager build-tools;28.0.3
    • sdkmanager extras;google;usb_driver
    • sdkmanager platforms;android-22 (which is enough for me, you may want something different based on your target Android devices) sdkmanager platforms;android-22 (对我来说足够了,根据你的目标Android设备你可能需要不同的东西)

Then open QtCreator, Go to "Mobile devices" (my french version calls it "Appareils mobiles"), then make it point to installed JDK, SDK, NDK, clic Apply and then kits should be automtically created. 然后打开QtCreator,转到“移动设备”(我的法语版本称之为“Appareils mobiles”),然后指向安装JDK,SDK,NDK,clic Apply,然后套件应自动创建。 Now you are ready to compile and deploy and Android app for API 22. 现在您已准备好为API 22编译和部署Android应用程序。

Note that gradle is automatically downloaded by QtCreator first time you'll request a deployment. 请注意,QtCreator会在您首次请求部署时自动下载gradle。

I have tried downgrading the SDK Tools which didn't work. 我试过降级SDK工具,但是没有用。 What worked for me however was downloading the official QT installer (working on Linux), installed QT to a new directory along with ARM64-v8a and ARMv7 (which probably solved the problem, I didn't have that in the package I installed from Arch repo). 然而,对我来说有用的是下载官方QT安装程序 (在Linux上工作),将QT安装到一个新目录以及ARM64-v8a和ARMv7(这可能解决了问题,我在Arch安装的软件包中没有回购)。 Now I can (after allowing the developer and debug mode on the device) deploy the app on the phone. 现在我可以(在允许设备上的开发人员和调试模式之后)在手机上部署应用程序。

EDIT: Then chose one of those auto-detected kits. 编辑:然后选择其中一个自动检测的工具包。

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

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