简体   繁体   English

无法在Qt Creator中构建Android APK

[英]Unable to build Android APK in Qt Creator

I am trying to build an android APK in Qt Creator 3.0.1 . 我正在尝试在Qt Creator 3.0.1中构建一个Android APK。 I have properly given the configured Android SDK, NDK, Ant, Java Jdk. 我已经正确地给出了配置的Android SDK,NDK,Ant,Java Jdk。 In Build Android APK step under Build there is a option to specify Android Build SDK ie target SDK. 在Build Android APK步骤下,可以选择指定Android Build SDK即目标SDK。 I am currenty using API 21 but it i am not getting an option to specify it over there. 我目前正在使用API​​ 21,但我没有选择在那里指定它。

Plz Help how can i do that. Plz帮助我该怎么做。

First you should select Tools > Options > Android to add paths to the Android NDK and SDK : 首先,您应选择工具>选项> Android以添加Android NDK和SDK的路径:

在此输入图像描述

Also select the Automatically create kits for Android tool chains option. 同时选择自动创建Android工具包套件选项。

For configuring deployment settings you should go to Projects > Build Android APK > Details Since Qt 5.4 along with QtCreator 3.3.0. 要配置部署设置,您应该转到项目>构建Android APK>详细信息自Qt 5.4以及QtCreator 3.3.0。 To create an APK package, select the Bundle Qt libraries in APK option : 要创建APK包,请在APK选项中选择Bundle Qt库

在此输入图像描述

You can also select Create Templates to create the manifest file to set application settings like icon, name, ... 您还可以选择“ 创建模板”以创建清单文件,以设置应用程序设置,如图标,名称,...

In previous versions of Qt and Qt Creator you should go to Projects->Run->Deploy . 在以前版本的Qt和Qt Creator中,您应该转到Projects-> Run-> Deploy

I recommend you to use the latest version of Qt and Qt Creator for Android development and deployment. 我建议您使用最新版本的Qt和Qt Creator进行Android开发和部署。

What helped me - switch off antivirus. 什么帮助我 - 关闭防病毒。 Why see below: 为什么看下面:

I've got the same error and reinstallation didn`t help. 我有同样的错误,重新安装没有帮助。

Runnning manually 'android.bat list targets' from cmd gives proper list of targets. 从cmd手动运行'android.bat list targets'可以给出正确的目标列表。

After digging into QtCreator code I found the reason - magic code for get list of targets in qt: 在深入研究QtCreator代码之后,我找到了原因 - 获取qt中目标列表的魔术代码:

void AndroidConfig::updateAvailableSdkPlatforms() const
{
    QProcess proc;
    proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
    proc.start(androidToolPath().toString(), QStringList() <<     QLatin1String("list") << QLatin1String("target")); // list avaialbe AVDs
    if (!proc.waitForFinished(10000)) {
        proc.terminate();
        return;
    }

As you can see if 'android.bat list target' cmd will not finish for 10 seconds qtcreator will just terminate the process. 正如您所看到的,'android.bat list target'cmd将无法完成10秒,qtcreator将终止该过程。

In my case it was 15 secs befor it finishes due to antivirus checks - so switching off antivirus could help in your case. 在我的情况下,由于防病毒检查,它完成了15秒 - 所以关闭防病毒可以帮助你的情况。

No need to restart QtCreator just open Android section in options again and all targets should be loaded. 无需重新启动QtCreator再次打开选项中的Android部分,并且应加载所有目标。

I 'love' Qt - it is always like this with it. 我爱'Qt - 它总是这样。

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

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