Qt configuration Android development environment, and .apk software release method

Qt version: 5.14.1

1 Preparing to install resources

  • JDK
  • SDK
  • GDR

Download link:

Link: https://pan.baidu.com/s/17AgHX0uW4ase2AKemP__VA 
Extraction code: ojnd

Among them, only the JDK needs to be installed, and the SDK and NDK can be decompressed!

2 Configure the environment

(1) Click Tools -> Options in Qt Creator

 (2) Device->Andriod, and then configure

  •  The JDK path can be automatically recognized after restarting
  • The paths of SDK and NDK need to be selected according to the file paths extracted in the previous step.

 When the above picture appears, the configuration is complete!

(3) Add an Android emulator and configure it

 

The parameters inside can be selected by yourself!

At this point, the development environment configuration is completed, and the Android project can be built!

3 Build the project

(1) Create a Qt application according to the following figure

 (2) Select the project path and enter the project name

 (3) Select the default in the following two steps, or change the class name by yourself

ui can also be selected according to your needs, it is recommended to select all!

 (4) This step is the translation of the engineering interface, generally select None 

(5) Select Kit kit, Android program development must select Andriod for ..., computer desktop application can be selected  by yourself

(6) Finally, click Finish

The next step is to develop Android applications!

4 Environmental testing

(1) Make a simple interface and write a program

The constructor writes the following program, click the button to display: Hello World!

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->pushButton,&QPushButton::clicked,this,[=](){
        ui->lineEdit->setText("Hello World!");
    });
}

 (2) Click Compile and select the debug device 

  •  It is recommended to choose a mobile phone for debugging, so that the speed is faster (here choose a mobile phone to connect to USB for debugging)
  • Simulator debugging requires higher computer configuration
  • Or find the xxx.spk file in the debug folder and send it to the mobile phone for installation to check the effect

 Mobile phone debugging method: connect the mobile phone to the computer USB, open the developer mode, and allow the device to be debugged through USB!

(3) Running effect: After installing it on the mobile phone, click the button to display Hello World!

 5 The compiled xxx.apk file can be directly run when sent to the mobile phone

File location: find the build-xxx-Android_for_armeabi_v7a_arm64_v8a_x86_x86_64 _Clang_Qt_5_14_2_for_Android-Debug folder in the project folder

 Enter the path under this folder: \android-build\build\outputs\apk\debug

 

Guess you like

Origin blog.csdn.net/jac_chao/article/details/124080651