Qt android development environment construction

I recommend a free open course of zero sound college. Personally, I think the teacher speaks well. I share it with you: Linux, Nginx, ZeroMQ, MySQL, Redis, fastdfs, MongoDB, ZK, streaming media, CDN, P2P, K8S, Docker, TCP/IP, collaboration, DPDK and other technical contents, learn immediately

Recently, I'm working on Qt Android related applications and recording the establishment of Android development environment
This chapter mainly implements Qt Android development environment

Build development environment

The Android development environment is currently built under windows and linux. The following describes the two environments. The QT version I use is Qt5 15.2. This needs to be downloaded online.
Download address https://download.qt.io/official_releases/online_installers/

Here, I downloaded QT unified windows x86 online Exe and QT unified Linux x64 online run

Construction of windows development environment

Install and build android development environment under windows

Qt online installation

First, you need to download the online installation tool, QT unified windows x86 online Exe, double click to open the software

Here you need to register an account on the Qt official website. Login account
Follow the steps below by default until the following interface appears. Be sure to select android

Then go to the next step until the installation is complete.

Qt Android development environment construction

After the above Android is completed, open the Qt development environment through tools - > Options - > device - > Android. As shown below

jdk needs to be installed. I have already installed it. I won't introduce it too much. You can configure jdk on Baidu online by yourself.
Next, install the Android SDK and NDK
To install the SDK, first click the Browse button, select where you want to install your SDK, and then click Set Up SDK. Just follow the default.
android_openssl, select the installation folder and click the Download OpenSSL button to download. It may not be able to download due to network reasons. You can download it at the following Baidu online disk address.

The following is the interface after installation and configuration

Development environment Baidu cloud Download:
Link: https://pan.baidu.com/s/1ewKbIB1PPN2F4gg1vaPj0w
Extraction code: ezlx
The above can be downloaded directly, decompressed and set up the relevant directory.

Construction of linux development environment

inux development environment, which I choose CentOS 7 Version 6, which is convenient for Porting linux related projects.
First, Download QT unified Linux x64 online Run, double-click to open.

It's the same as the front installation
After the installation, it was found that QT creator could not be opened. It was found that there was a problem with the environment. The solution was to install another qtcreator. After many tests, it is found that QT creator opensource Linux x86_ 64-4.13.3. The qtcreator of run is OK, because it needs to download the Android development environment, and other versions may not be downloaded.
Download address: https://download.qt.io/archive/qtcreator/4.13/4.13.3/qt-creator-opensource-linux-x86_64-4.13.3.run
The installation configuration is consistent with that of windows

Development test

For the development environment, select Android QT 5.15.2 clang multi abi.

Simple test

Develop and introduce third-party libraries

Here, use the vlc development environment
Download VLC Android development library first: https://mirrors.aliyun.com/videolan/vlc-android/3.4.3/

Change the downloaded apk into zip and unzip it,

Get libvlc So file, you can use vlc normally.

Test vlc part code

#include "widget.h"

#include <QApplication>
#include <vlc/vlc.h>
#include <QDebug>
#include <QMutex>
#include "main.h"

struct Context {
    QMutex mutex;
    uchar *pixels;

CIns* CIns::m_ins = nullptr;

static void *lock(void *opaque, void **planes)
    struct Context *ctx = (struct Context *)opaque;

    // Tell VLC to put the decoded data into the buffer
    *planes = ctx->pixels;

    return nullptr;

// Get argb picture and save to file
static void unlock(void *opaque, void *picture, void *const *planes)

    struct Context *ctx = (struct Context *)opaque;
    unsigned char *data = static_cast<unsigned char *>(*planes);
    static int frameCount = 1;

    QImage image(data, 512, 288, QImage::Format_ARGB32);
//    image.save(QString("frame_%1.png").arg(frameCount++));
    emit CIns::Ins()->SigImage(image);


static void display(void *opaque, void *picture)


int main(int argc, char *argv[])
    QApplication a(argc, argv);
    Widget w;
    QObject::connect(CIns::Ins(), &CIns::SigImage, &w, &Widget::SlotImage);
    const char* const vlc_args[] = {
            "--network-caching=500",	//Network extra cache value (ms)
            "--rtsp-tcp",				//RTSP adopts TCP transmission mode

    libvlc_instance_t * inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;
    struct Context ctx;
    ctx.pixels = new uchar[512 * 288 * 4];
    memset(ctx.pixels, 0, 512 * 288 * 4);

    //libvlc_time_t length;

    /* Load the VLC engine */
    inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
    QString strUrl = "rtsp://wowzaec2demo.streamlock.net/vod/mp4";
    m = libvlc_media_new_location (inst, strUrl.toStdString().c_str());
    mp = libvlc_media_player_new_from_media (m);
//    libvlc_media_player_set_hwnd(mp, (void *)wgt.winId());

    // Set callback to extract frames or display them on the interface.
    libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx);
    libvlc_video_set_format(mp, "RGBA", 512, 288, 512 * 4);

    libvlc_media_release (m);
    libvlc_media_player_play (mp);

    int ret = a.exec();

    libvlc_media_player_stop (mp);

    // Free the media_player
    libvlc_media_player_release (mp);

    libvlc_release (inst);

    return ret;

Test vlc playback

Full code address:
Link: https://pan.baidu.com/s/1m9X3zvPqNEaTPlGhnWR1VQ
Extraction code: gok4

Reference documents

Configure Qt5 12.3 Android development environment
Qt5.14.2 add a third-party library (. A,. so) to the Android project
Common writing method of introducing third-party library into cmake compilation of android Development

Keywords: Linux Android cmake Qt

Added by fat creative on Sat, 12 Feb 2022 18:49:59 +0200