Can't get APK built with correct targetSDK Qt Creator 5.15.2
-
I’m trying to upgrade our target SDK from 28 to 34 ; so I did the following:
- Opened our projects project\android-build\gradle.properties file and changed targetApi=34
- Went into Qt Creator and selected:
However, after building, if I do a diff of my build-xxx-Android_Qt_5_15_2_Clang_Multi_Abi-Debug\project\android-build\gradle.properties I see this:
BOTH qtMinSdkVersion=21 AND qtTargetSdkVersion=28 are wrong. My minSdkVersion = 30 under defaultConfig in project\android\build.gradle and obviously I selected targetSdk of 34 in Qt Creator
If I use aapt.exe from SDK34 to dump the resulting APK I see the following:
Line 843: A: android:minSdkVersion(0x0101020c)=(type 0x10)0x1e -> 30
Line 844: A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c -> 28So clearly this makes no sense as the targetSdk is < the minSdk ; what am I doing wrong??
-
@Vince_SiriusXM I've managed to reproduce this issue using the analogclock example that comes with Qt 5.15.2 .
Can ANYONE get this example design to build for Android with a targetSDK of 34? If so how? -
@Vince_SiriusXM
I use the version 31 -
@Vince_SiriusXM 5.15.2 "For version 5.15.2, when compiling Android programs, you need JDK 11.0.2, NDK 21.3.6528147, and Android tool version 29 and build-platforms-android-29 . Make sure these requirements are met to compile successfully. There seems to be a strange bug in Qt Creator 12.02 where even though the configurations are set correctly, it still displays errors. However, the compilation can proceed. Another bug is that after setting up as mentioned above, sometimes you can't select 'android-tool-version 29' and 'build-platforms' the next time." I'm not sure if my English grammar is correct, but this is what I've figured out after spending several days trial and error. Unfortunately, I can't upload images here, otherwise I wouldn't need AI assistance to translate it into English to inform you.
-
@Vince_SiriusXM When you encounter issues, revert the JDK back to JDK 17, restart, then set it to JDK 11, Android 29, NDK 21! If possible, switch to Qt 6; I haven't found any bugs so far, but there isn't much learning material available compared to Qt 5! Ugh, why did I choose to learn Qt for Android when I already know Java? These bugs are causing me so much pain
-
@Vince_SiriusXM You can download the file from https://dl.google.com/android/repository/commandlinetools-win-9123335_latest.zip and then replace the files in the corresponding folder in the SDK. After that, QtCreator should work properly. Remember to use JAVA11 and NDK21.
-
@Vince_SiriusXM Good news, after replacing the files downloaded above with the SDK files, I can now successfully compile using platform 34 as long as JDK11 is confirmed!
-
@jack_study_qt said in Can't get APK built with correct targetSDK Qt Creator 5.15.2:
@Vince_SiriusXM Good news, after replacing the files downloaded above with the SDK files, I can now successfully compile using platform 34 as long as JDK11 is confirmed!
Did you "Create Templates" for Android and if so what values you select for :
Also which ABI(s) did you build for?
Thank you for reply btw!!
-
@jack_study_qt said in Can't get APK built with correct targetSDK Qt Creator 5.15.2:
@Vince_SiriusXM You can download the file from https://dl.google.com/android/repository/commandlinetools-win-9123335_latest.zip and then replace the files in the corresponding folder in the SDK. After that, QtCreator should work properly. Remember to use JAVA11 and NDK21.
which is the exact folder to replace with these?
-
@Vince_SiriusXM After several days of testing, it has been confirmed how to configure the Android environment for QT 5.15.2 with JDK 11 and the necessary Android packages downloaded. However, your QtCreator still encounters errors because the SDK you have installed only supports JDK 17, whereas QT 5 is limited to supporting JDK 11. The solution is as follows: In the SDK installation directory, locate cmdline-tools, enter it, and then click on latest. From the following website, choose the corresponding cmdline tools version compatible with JDK 11 and directly overwrite the original files. Voila! Your QtCreator should now be free of errors. Oh, is the Android QT version still showing up in red? Clear the cache in QtCreator. If not for having one computer working flawlessly while another one encountered issues, I wouldn't have discovered this bug. Lastly, note that the compilation platform targeting API 31 produces the fewest and most optimal results; do not use a version greater than 31. If you're still encountering problems, carefully review my post to ensure you haven't missed any crucial steps—every detail counts. Replacing cmdline-tools is absolutely essential; let me emphasize this point thrice.
{
"sdk_tools_url": {
"linux": "https://dl.google.com/android/repository/commandlinetools-linux-9123335_latest.zip",
"linux_sha256": "0bebf59339eaa534f4217f8aa0972d14dc49e7207be225511073c661ae01da0a",
"windows": "https://dl.google.com/android/repository/commandlinetools-win-9123335_latest.zip",
"windows_sha256": "8a90e6a3deb2fa13229b2e335efd07687dcc8a55a3c544da9f40b41404993e7d",
"mac": "https://dl.google.com/android/repository/commandlinetools-mac-9123335_latest.zip",
"mac_sha256": "d0192807f7e1cd4a001d13bb1e5904fc287b691211648877258aa44d1fa88275"
}
} -
@Vince_SiriusXM 31.00 android-31
-
My original goal when I started this thread was to compile in QT 5.15.2 for Android with targetSDK = 34.
After reading through all the posts carefully and experimenting myself it seems like that may be impossible without moving to a newer version of Qt (possibly 5.15.16 or 6+?) and hence I'm stuck at targetSDK = 31 ?
Is that the general consensus? -
@Vince_SiriusXM No, I have successfully compiled using the 34api, but I haven't tested if the functionality is correct. QT5.15.X can only use JDK11, and 34API can be used. You must do as I said above to make qtcreator work properly and use JDK11 without errors.
-
@Vince_SiriusXM targetSDK = 34? I don't have that kind of phone, haven't tried it. In QT5.15.2, I've only used build-platform 34 android34.
-
@jack_study_qt After you successfully built for 31API or 34API, go into your build directory and open the files:
C:\Qt\Examples\Qt-5.15.2\gui\build-gui-Android_Qt_5_15_2_Clang_Multi_Abi-Debug\analogclock\android-build\gradle.properties
and
C:\Qt\Examples\Qt-5.15.2\gui\build-gui-Android_Qt_5_15_2_Clang_Multi_Abi-Debug\analogclock\android-build\build.gradleWhat does it show for the variables:
minSdkVersion =
targetSdkVersion = -
@Vince_SiriusXM
make: Nothing to be done for 'qmake_all'.
16:30:31: 进程"D:\android\sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe"正常退出。
16:30:31: 正在启动 "D:\android\sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe" -j8make: Nothing to be done for 'first'.
16:30:31: 进程"D:\android\sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe"正常退出。
16:30:31: 移除目录 E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-build/libs
16:30:31: 正在启动 "D:\android\sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe" "INSTALL_ROOT=E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-build" install && cd E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug && D:\android\sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe "INSTALL_ROOT=E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-build" installD:\Qt\5.15.2\android\bin\qmake.exe -install qinstall -exe libuntitled3_x86_64.so E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-build\libs\x86_64\libuntitled3_x86_64.so
D:\Qt\5.15.2\android\bin\qmake.exe -install qinstall -exe libuntitled3_x86_64.so E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-build\libs\x86_64\libuntitled3_x86_64.so
16:30:32: 进程"D:\android\sdk\ndk\21.3.6528147\prebuilt\windows-x86_64\bin\make.exe"正常退出。
16:30:32: 正在启动 "D:\Qt\5.15.2\android\bin\androiddeployqt.exe" --input E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-untitled3-deployment-settings.json --output E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build --android-platform android-34 --jdk D:/Java/jdk-11.0.22 --gradleGenerating Android Package
Input file: E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-untitled3-deployment-settings.json
Output directory: E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build/
Application binary: untitled3
Android build platform: android-34
Install to device: No
-- Skipping D:/Qt/5.15.2/android/plugins/generic/libplugins_generic_insighttrackerplugin_x86_64.so. It has unmet dependencies: lib/libQt5InsightTracker_x86_64.so,lib/libQt5Network_x86_64.so,lib/libQt5Sql_x86_64.so.
-- Skipping D:/Qt/5.15.2/android/plugins/iconengines/libplugins_iconengines_qsvgicon_x86_64.so. It has unmet dependencies: lib/libQt5Svg_x86_64.so.
-- Skipping D:/Qt/5.15.2/android/plugins/imageformats/libplugins_imageformats_qsvg_x86_64.so. It has unmet dependencies: lib/libQt5Svg_x86_64.so.
Skipping createRCC
Starting a Gradle Daemon, 3 incompatible and 3 stopped Daemons could not be reused, use --status for details
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: 意外的元素 (uri:"", local:"extension-level")。所需元素为<{}codename>,<{}layoutlib>,<{}api-level>
Warning: 意外的元素 (uri:"", local:"base-extension")。所需元素为<{}codename>,<{}layoutlib>,<{}api-level>Task :preBuild UP-TO-DATE
Task :preDebugBuild UP-TO-DATE
Task :compileDebugAidl UP-TO-DATE
Task :compileDebugRenderscript NO-SOURCE
Task :generateDebugBuildConfig UP-TO-DATE
Task :javaPreCompileDebug UP-TO-DATE
Task :mainApkListPersistenceDebug UP-TO-DATE
Task :generateDebugResValues UP-TO-DATE
Task :generateDebugResources UP-TO-DATE
Task :mergeDebugResources UP-TO-DATE
Task :createDebugCompatibleScreenManifests UP-TO-DATE
Task :extractDeepLinksDebug UP-TO-DATE
Task :processDebugManifest UP-TO-DATE
Task :processDebugResources UP-TO-DATE
Task :compileDebugJavaWithJavac UP-TO-DATE
Task :compileDebugSources UP-TO-DATE
Task :mergeDebugShaders UP-TO-DATE
Task :compileDebugShaders UP-TO-DATE
Task :generateDebugAssets UP-TO-DATE
Task :mergeDebugAssets UP-TO-DATE
Task :processDebugJavaRes NO-SOURCE
Task :mergeDebugJavaResource UP-TO-DATE
Task :checkDebugDuplicateClasses UP-TO-DATE
Task :desugarDebugFileDependencies UP-TO-DATE
Task :mergeExtDexDebug UP-TO-DATE
Task :mergeLibDexDebug UP-TO-DATE
Task :dexBuilderDebug UP-TO-DATE
Task :mergeProjectDexDebug UP-TO-DATE
Task :mergeDebugJniLibFolders UP-TO-DATE
Task :mergeDebugNativeLibs UP-TO-DATE
Task :stripDebugDebugSymbols UP-TO-DATE
Task :validateSigningDebug UP-TO-DATE
Task :packageDebug UP-TO-DATE
Task :assembleDebug UP-TO-DATEBUILD SUCCESSFUL in 15s
26 actionable tasks: 26 up-to-date
Android package built successfully in 17.746 ms.
-- File: E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build//build/outputs/apk/debug/android-build-debug.apk
16:30:50: 进程"D:\Qt\5.15.2\android\bin\androiddeployqt.exe"正常退出。
16:30:50: 启动:D:\Qt\5.15.2\android\bin\androiddeployqt.exe --verbose --output E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build --no-build --input E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-untitled3-deployment-settings.json --gradle --reinstall --device emulator-5554
Generating Android Package
Input file: E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-untitled3-deployment-settings.json
Output directory: E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build/
Application binary: untitled3
Android build platform: android-34
Install to device: emulator-5554
Detecting dependencies of application.
Reading dependencies from E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build//libs/x86_64/libuntitled3_x86_64.so
lib/libQt5Core_x86_64.so
lib/libQt5Gui_x86_64.so
lib/libQt5Widgets_x86_64.so
Reading dependencies from D:/Qt/5.15.2/android/lib/libQt5Core_x86_64.so
Appending dependency: lib/libQt5Core_x86_64.so
Reading dependencies from D:/Qt/5.15.2/android/lib/libQt5Gui_x86_64.so
lib/libQt5Core_x86_64.so
Appending dependency: lib/libQt5Gui_x86_64.so
Reading dependencies from D:/Qt/5.15.2/android/lib/libQt5Widgets_x86_64.so
lib/libQt5Core_x86_64.so
lib/libQt5Gui_x86_64.so
Appending dependency: lib/libQt5Widgets_x86_64.so
Reading Android dependencies for Qt5Core_x86_64
Reading Android dependencies for Qt5Gui_x86_64
Appending dependency from xml: plugins/platforms/libplugins_platforms_qtforandroid_arm64-v8a.so
Appending dependency from xml: plugins/platforms/libplugins_platforms_qtforandroid_armeabi-v7a.so
Appending dependency from xml: plugins/platforms/libplugins_platforms_qtforandroid_x86.so
Appending dependency from xml: plugins/platforms/libplugins_platforms_qtforandroid_x86_64.so
Appending dependency from xml: plugins/generic/libplugins_generic_insighttrackerplugin_arm64-v8a.so
Appending dependency from xml: plugins/generic/libplugins_generic_insighttrackerplugin_armeabi-v7a.so
Appending dependency from xml: plugins/generic/libplugins_generic_insighttrackerplugin_x86.so
Appending dependency from xml: plugins/generic/libplugins_generic_insighttrackerplugin_x86_64.so
Appending dependency from xml: plugins/iconengines/libplugins_iconengines_qsvgicon_arm64-v8a.so
Appending dependency from xml: plugins/iconengines/libplugins_iconengines_qsvgicon_armeabi-v7a.so
Appending dependency from xml: plugins/iconengines/libplugins_iconengines_qsvgicon_x86.so
Appending dependency from xml: plugins/iconengines/libplugins_iconengines_qsvgicon_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qgif_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qgif_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qgif_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qgif_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qicns_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qicns_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qicns_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qicns_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qico_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qico_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qico_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qico_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qjpeg_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qjpeg_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qjpeg_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qjpeg_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qsvg_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qsvg_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qsvg_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qsvg_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtga_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtga_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtga_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtga_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtiff_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtiff_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtiff_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qtiff_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwbmp_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwbmp_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwbmp_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwbmp_x86_64.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwebp_arm64-v8a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwebp_armeabi-v7a.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwebp_x86.so
Appending dependency from xml: plugins/imageformats/libplugins_imageformats_qwebp_x86_64.so
Reading Android dependencies for Qt5Widgets_x86_64
Appending dependency from xml: plugins/styles/libplugins_styles_qandroidstyle_arm64-v8a.so
Appending dependency from xml: plugins/styles/libplugins_styles_qandroidstyle_armeabi-v7a.so
Appending dependency from xml: plugins/styles/libplugins_styles_qandroidstyle_x86.so
Appending dependency from xml: plugins/styles/libplugins_styles_qandroidstyle_x86_64.so
Reading dependencies from D:/Qt/5.15.2/android/plugins/platforms/libplugins_platforms_qtforandroid_x86_64.so
lib/libQt5Core_x86_64.so
lib/libQt5Gui_x86_64.so
Scanning for QML imports.
Running qmlimportscanner with the following command: D:/Qt/5.15.2/android/bin/qmlimportscanner.exe -rootPath E:/Cplus/untitled3/ -importPath D:/Qt/5.15.2/android/qml E:/Cplus/untitled3/
Copying 1 dependencies from Qt into package.
Copying STL library
-- Skipping file D:\android\sdk\ndk\21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/lib//x86_64-linux-android/libc++_shared.so. Same or newer file already in place.
Skipping createRCC
Installing Android package to device.
Running command "D:/android/sdk/platform-tools/adb.exe -s emulator-5554 install -r E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build//build/outputs/apk/debug/android-build-debug.apk"
Performing Streamed Install
Success
Android package built successfully in 1.815 ms.
-- It can now be run from the selected device/emulator.
-- File: E:/Cplus/build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug/android-build//build/outputs/apk/debug/android-build-debug.apk
16:30:52: 进程“D:\Qt\5.15.2\android\bin\androiddeployqt.exe”正常退出。
16:30:52: 正在读取调试需要的文件。
16:30:52: 包部署:运行命令“D:\android\sdk\platform-tools\adb.exe -s emulator-5554 pull /system/bin/app_process64 E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-app-process\app_process”。
16:30:52: 包部署:运行命令“D:\android\sdk\platform-tools\adb.exe -s emulator-5554 pull /system/bin/linker64 E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-app-process\linker64”。
16:30:53: 包部署:运行命令“D:\android\sdk\platform-tools\adb.exe -s emulator-5554 pull /system/lib64/libc.so E:\Cplus\build-untitled3-Qt_5_15_2_Clang_Multi_Abi-Debug\android-app-process\libc.so”。
16:30:53: Elapsed time: 00:22. -
@Vince_SiriusXM <uses-sdk android:targetSdkVersion="31" android:minSdkVersion="31"/> <supports-screens android:normalScreens="true" android:smallScreens="true" android:largeScreens="true" android:anyDensity="true"/> <!-- %%INSERT_PERMISSIONS --> <!-- %%INSERT_FEATURES --> </manifest> Using JDK11, NDK21, and an Android build platform of android-34 (repeated twice), under these settings, the API 34 emulator successfully compiles, but the APP fails to run! The API 31 emulator compiles successfully, and the APP runs normally! However, the API 29 emulator cannot compile. Despite this, the following content remains unchanged:
android.bundle.enableUncompressedNativeLibs=false androidBuildToolsVersion=34.0.0 androidCompileSdkVersion=34 buildDir=build qt5AndroidDir=D:/Qt/5.15.2/android/src/android/java qtMinSdkVersion=21 qtTargetSdkVersion=28!This must be a bug in QtCreator, right? Otherwise, why can't the API 29 emulator compile? This tool has plenty of bugs, ha ha. Perhaps you could use QJN to call native Android APIs and check what the actual TargetSdkVersion is. Actually, I misunderstood your question earlier; I thought you were trying to solve a compilation issue, whereas you actually want to determine the TargetSdkVersion. In my testing, it doesn't seem to display correctly.
-
@Vince_SiriusXM "Hehe, it might be because the NDK version is not high enough. Don't bother trying JDK 17; it won't compile. Start testing from version 22 onwards