QT builds Android compilation environment and uses Android virtual machine to debug

QT can create Android APP, and at the same time generate apk for installation.

In order to compile and generate apk, you need to add the corresponding support package for QT.

1. Android environment support package download

1、JAVA SE8 JDK

JAVA SE8 JDK is a support package for the JAVA environment. Android APPs are usually written in the JAVA area, but you can use C/C++ directly with QT. In fact, QT automatically converts C/C++ to JAVA, and finally uses JAVA, so you need JAVA Compiler Environment.

But there will be a problem here. There are many versions of JAVA SE JDK, and the latest version is already JAVA SE20. However, after actual testing, JAVA SE20 cannot be used, and an error will be prompted when compiling. After checking a lot of information and sharing the experience of others, JAVA SE8 JDK is the most normal version.

This article does not provide a link for now, please download JAVA SE8 JDK by yourself.

Open the JDK installation package, the jdk part will be installed first (jdk+jre in the installation package)

Click Next,

 After changing or remembering the installation path, click Next,

 

After the installation is complete, a jre installation will pop up, also click Next, after changing or remembering the installation path, wait for the paw to complete for you.

 After all the support packages are installed, set them in QT uniformly and continue to the next support package.

2、Android SDK Tools

One of the Android compilation environments.

Download address: https://www.androiddevtools.cn/

 

After the download is complete, unzip, change or remember the unzipped file path.

Open the unzipped android-sdk-windowsfolder, run SDK Manager.exethe software,

 Install the following parts:

 Click Install packages to install.

The purpose of only installing API 24 here is to use it for later debugging of simulated Android devices. If you have an Android phone on hand that can be connected to a PC for debugging, you can install a higher version of the API.

After the SDK installation is complete, run AVD Manager.exethe software,

Create an Android virtual machine,

 My configuration is as follows:

 Click OK, so that you can use the Android virtual machine to debug the APP in QT later.

Continue to the next support package.

3、Android NDK

One of the Android compilation environments.

Download link: https://github.com/android/ndk/wiki/Unsupported-Downloads

Note: NDK has requirements for the QT version. The QT I use is version 5.11, and the last version is r12b. If it is version 5.13, you can use r18b.

Just decompress the NDK, change or remember the decompressed file path.

All the support packages have been downloaded, and the QT environment configuration starts.

Two, QT configuration Android environment

I won’t introduce how to install QT here. There are a bunch of tutorials on the Internet, just talk about how to configure it.

open options,

 

According to the corresponding prompt, select the folder paths of the three support packages just now, and click OK or Apply.

At this point, you can see the Android virtual machine we just created in the AVD management.

 At this point, be aware that a warning will appear,

If this warning appears, you need to check whether the kits can be used.

 

This case in the picture is available.

If there is a red exclamation mark in these two items, it means that the environment is abnormal, and the NDK version needs to be reduced or increased. 

In this way, the environment is set up, and you can create an APP project, and select the created Android virtual machine when compiling.

Because the error of When executing step "Build Android APK" appeared when I used the real machine test, I simply used the Android virtual machine to debug, and after the debugging was successful, I sent the apk (apk will be automatically generated after QT debugging and compilation is successful) to the mobile phone for installation.

 

Guess you like

Origin blog.csdn.net/weixin_39457767/article/details/130532656