Cannot select API 33 for Android Target SDK in QT Creator
-
@JoeCFD I have been struggling with this issue for days and only updated to java 17 right before I posted here. It doesn't seem to matter what version of java I'm using or which SDKs are installed or not installed. The only choices I get in the manifest editor are API 16 through API 31.
-
-
@TheCrowKaka In the following my working configuration. (Qt 5.15)
I installed Open JDK 18:
JDK-Path: /usr/lib/jvm/java-18-openjdk-amd64Set my target SDK in *.pro:
ANDROID_TARGET_SDK_VERSION = 33
Updated gradle.properties:
org.gradle.jvmargs=-Xmx2048m androidBuildToolsVersion=33.0.2 androidCompileSdkVersion=33 qtMinSdkVersion=21 qtTargetSdkVersion=33 android.useAndroidX=true android.enableJetifier=true
Updated gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists # use newer gradle version, in order to work with JDK 18 distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
Updated build.gradle:
buildscript { repositories { google() // note: you cant use jcenter() anymore mavenCentral() maven { url 'https://jitpack.io' } } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' } } repositories { google() mavenCentral() maven { url 'https://jitpack.io' } } apply plugin: 'com.android.application' // you won't need all of my dependencies, I require them for my JNI parts // note: if you have some legacy android stuff, you have to fix the imports to use androidx // e.g. // OLD IMPORTS // import android.support.v4.content.FileProvider; // import android.support.v4.app.ShareCompat; // NEW IMPORTS // import androidx.core.content.FileProvider; // import androidx.core.app.ShareCompat; dependencies { // note the new keywords here, as some got deprecated // e.g. old depency: // compile "com.android.support:support-v4:24.+" implementation 'androidx.core:core:1.3.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.32" implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72" implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) }
If you can't select "android-33" in the build config view, you can try to manually add the options to your *.pro.user file, and then restart QtCreator:
ProjectExplorer.BuildStepList.Step.3:
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.3"> <value type="QString" key="BuildTargetSdk">android-33</value>
ProjectExplorer.Target.PluginSettings:
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"> <value type="int" key="AndroidVersion.ApiLevel">33</value>
Note: If you can select a different Android Version (e.g. 26), you might be able to simply search for "26".
(in my case I have 4 occurrences for '33'; 3 x within 'ProjectExplorer.BuildStepList.Step.3' and 1 x within 'ProjectExplorer.Target.PluginSettings') -
-
@TheCrowKaka Having the same problem here.
And absolutely no solution in sight. I am using Qt 6.6 on MacOs 14.1.1 with JDK-17.
Will try OpenJdk 18, but only after I have cooled down a bit :-PWhat I ask myself - when editing AndroidManifest.xml in QtCreator: where does it get the list of possible API-Levels from? Couldn't this be a point where to find a solution...?
-
@klausix I feel your pain.
I am using Qt 6.6.1 on Windows 10 and managed to find a solution to this. I am successfully building my app for platform API-33 using API-33 tools. It's luck not competence that has got me there, but this, in short, is what I did.
-
uninstalled Android Studio
-
uninstalled the Android SDK
-
installed Qt 6.6.1 - probably irrelevant, I was using 6.6.0
-
removed the JDK 11 installation I was using
-
used the QtCreator Edit => Preferences => Devices => Android => JDK Location "globe" button to install JDK 17 from the default location it offers https://adoptium.net and set the JDK location
-
used SDK Manager on the same dialog to install as follows:
-
key step: edit the gradle.properties file in MyApp/android directory to contain:
androidBuildToolsVersion=33.0.0 androidCompileSdkVersion=33 androidNdkVersion=25.1.8937393 buildDir=build qt5AndroidDir=E:/Qt/6.6.1/android_arm64_v8a/./src/android/java qtAndroidDir=E:/Qt/6.6.1/android_arm64_v8a/./src/android/java qtMinSdkVersion=23 qtTargetAbiList=arm64-v8a qtTargetSdkVersion=33 android.suppressUnsupportedCompileSdk=33
[In my project this file was created some time ago via the "Create Templates" option when I was using Qt 6.5.3 . It originally contained no equivalent of the quoted section.]
- remove the app build directories
- remove the project CMakeLists.txt.user file
- restart QtCreator and load the application CMake project
- in Projects => Android Qt 6.6.1 Clang arm-64-v8a => Build => Build Android APK => Application set Android build platform SDK to android-33 (android-31 was also offered.) The Android build-tools version was stuck on 31
The app then built in a Debug buld without problems and ran okay on a Pixel 7 running Android 14.
I then connected a Pixel 4a running Android 13 to another USB port. Qt Creator crashed after about 30 seconds of spinning. When I restarted it the option to use build-tools 33 was available. Now both Release and Debug builds are fine. -
-
The gradle.properties file contains
android.suppressUnsupportedCompileSdk=33
as recommended by the warning that is issued by the build if you leave this out. The warning is that gradle plugin 7.2.1 has not been tested against android API-33.
This seems to be in contradiction to the information here:
https://developer.android.com/build/releases/gradle-plugin#groovy
which appears to say that Android Gradle Plugin (AGP) version 7.2 is valid for API-33
Also, as mentioned in this post:
https://forum.qt.io/topic/151244/online-installed-android-qt-6-6-but-build-requires-newer-version
by @shokarta Qt insists on installing the android SDK for API 31, whether you want it or not.I suspect both of these are bugs which can be ignored. But they do compound the general confusion.
-
Here is the solution :
build.gradle in android directory
1 - Version must be 7.4.2 or newer
dependencies { classpath 'com.android.tools.build:gradle:7.4.2' }
2 - Set targetSdkVersion manually
defaultConfig { resConfig "en" minSdkVersion qtMinSdkVersion targetSdkVersion 33 ndk.abiFilters = qtTargetAbiList.split(",") }
gradle-wrapper.properties in android/gradle/wrapper directory
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists -