Qt6 for android environment construction

ready to operate

System: win10 orlinux (basically the same)

Software: androidStudio, Qt6, java jdk11 (use version 17 with a warning prompt above 1.8, the installation in the text is still written jdk1.8, and jdk11 is actually used for later compilation)

1. Qt installation as shown below:

Log in to your account 

 I have already installed it, so choose to add it here

 Filter on the right as long as lts and release version

 Here I choose the latest version of Qt by default, select Android, and then wait for the next step to complete. Other configurations can be selected according to your own needs.

2. The next step is to select version 1.8 of jdk (here according to jdk1.8 configuration, just replace it with jdk11 or above)

        The installation path is free to install and omitted, and the configuration environment is as follows:

 find advanced system settings

 Select Environment Variables in the lower right corner

 The first is to create a new (system) variable variable name: JAVA_HOME   variable value is the jdk environment path

 

Then go ahead and add: 

variable  nameCLASSPATH

Variable value  .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; 

Note that there is a dot in front of the variable value and a semicolon at the end 

 

 Then add it to the path:

%JAVA_HOME%\bin

%JAVA_HOME%\jre\bin

         Test the java environment (because the java17 I use shows a different version number) Shortcut key win+R Enter cmd to call out the command line: 

        

3. Let's install androidStudio (mainly for sdk and ndk)

The installation process is only briefly explained to download sdk, ndk

 androidStudio select sdkManage to configure

 Choose whichever Android version you need

 Here is the ndk configuration 

Then apply in the lower right corner and wait for 10 to 30 minutes to close the software after waiting for completion.

4. Qt configuration

 Enter the configuration interface as follows:

After configuration, apply first and then reopen QtCreator

Enter again and choose to enter the kit interface this time:

 It can be seen that everything in the kit is normal.

Then cut the version compiler debug as follows:

 

Then create a new project to see if there is an Android option

 

Then, test the project (empty direct compilation):

 The tool will be downloaded in the middle and wait for a while:

 

Compile and pass after replacing jdk11 according to the warning

Replace jdk operation Refer to the previous jdk installation process. 

5. Now configure the Android project

        

enter configuration

Create a signing key:

 

After saving:

Then configure the sdk and other information of the apk:

 apk template follow-up configuration

Then a dialog box pops up and after confirmation:

 

Recompile after configuration:

 

 Add a test popup:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
  Q_OBJECT

public:
  MainWindow(QWidget *parent = nullptr);
  ~MainWindow();

private slots:
  void on_pushButton_clicked();

private:
  Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
void MainWindow::on_pushButton_clicked() {

  QMessageBox::information(this, "smaller",
                           "this is my first android proaram!");
}

The program is also signed. If the icon is configured before, the program will have an icon.

Test the app kit on armV7:

Compiled path File: D:/work/build-testAndroid-Android_Qt_6_2_3_Clang_armeabi_v7a-Release/android-build//build/outputs/apk/release/android-build-release-signed.apk

Copy the mobile phone installation to see 

 

Guess you like

Origin blog.csdn.net/u011624093/article/details/123474551