Built my QT app for Android with API level 30 (Android 11)

New Android App Bundle and target API level requirements in 2021:

Starting August 2021, new apps will be required to target API level 30 (Android 11) and use the Android App Bundle publishing format. Starting November 2021, all app updates will be required to target API level 30 (Android 11). Apps with a download size of more than 150 MB are now supported by Play Asset Delivery and Play Feature Delivery.

I updated the manifest manually as follows:

<?xml version="1.0"?>
<manifest package="net.geographx.LinesGame" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.5.30" android:versionCode="161" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>

And tried to build the app with QT Creator 4.15.1 and the following settings:

JAVA_HOME=C:/Program Files/Android/Android Studio/jre

But got the following error:

Cannot find jarsigner in JAVA_HOME or PATH. Please use --jdk option to pass in the correct path to JDK.
16:00:41: The process "E:\Qt\Qt5.15.2\android\bin\androiddeployqt.exe" exited with code 15.
Error while building/deploying project LinesGameQt (kit: Android Qt 5.15.2 (android) Clang Multi-Abi)
When executing step "Build Android APK"

It is not clear why, but when I create a Java project in Android Studio, its JDK location is this folder:

I installed Oracle JDK 16 containing jarsigner.exe in its bin directory and set

JAVA_HOME=C:\Program Files\Java\jdk-16.0.1

but got:

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 607ms
Building the android package failed!
  -- For more information, run this command with --verbose.
16:58:03: The process "E:\Qt\Qt5.15.2\android\bin\androiddeployqt.exe" exited with code 14.
Error while building/deploying project LinesGameQt (kit: Android Qt 5.15.2 (android) Clang Multi-Abi)
When executing step "Build Android APK"

After that I figured out that JDK 11 or earlier must be used when using Qt for Android and I installed Oracle JDK 11, so the path became:

JAVA_HOME=C:\Program Files\Java\jdk-11.0.11

but got this again:

Cannot find jarsigner in JAVA_HOME or PATH. Please use --jdk option to pass in the correct path to JDK.
17:10:01: The process "E:\Qt\Qt5.15.2\android\bin\androiddeployqt.exe" exited with code 15.
Error while building/deploying project LinesGameQt (kit: Android Qt 5.15.2 (android) Clang Multi-Abi)
When executing step "Build Android APK"

Updated JDK location in QT Creator settings:

So the command line became:

18:34:40: The process "C:\Users\D-Ef\AppData\Local\Android\Sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe" exited normally.
18:34:40: Starting: "E:\Qt\Qt5.15.2\android\bin\androiddeployqt.exe"
    --input E:/repos/build/lgA/android-LinesGameQt-deployment-settings.json
    --output E:/repos/build/lgA/android-build
    --android-platform android-30
    --jdk "C:/Program Files/Java/jdk-11.0.11"
    --gradle
    --aab
    --jarsigner
    --sign ****** --storepass ******
Generating Android Package
  Input file: E:/repos/build/lgA/android-LinesGameQt-deployment-settings.json
  Output directory: E:/repos/build/lgA/android-build/
  Application binary: LinesGameQt
  Android build platform: android-30
  Install to device: No

and it started to build.

Links:

1 Response to Built my QT app for Android with API level 30 (Android 11)

  1. Very, very interesting article! Really interesting ?

Leave a Reply

Your email address will not be published. Required fields are marked *