how to select android target API level?
-
Hi @kgregory, you want to set the
ANDROID_TARGET_SDK_VERSION
project variable.If you are using a *.pro file you can simply add this line:
ANDROID_TARGET_SDK_VERSION = 34
If you're using CMake with a currently-supported version of Qt 6, see https://doc.qt.io/qt-6/cmake-target-property-qt-android-target-sdk-version.html
-
Hi @kgregory, you want to set the
ANDROID_TARGET_SDK_VERSION
project variable.If you are using a *.pro file you can simply add this line:
ANDROID_TARGET_SDK_VERSION = 34
If you're using CMake with a currently-supported version of Qt 6, see https://doc.qt.io/qt-6/cmake-target-property-qt-android-target-sdk-version.html
@JKSH hmm, now I get this
here is my android manifest
<?xml version="1.0"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="myapp" android:installLocation="auto" android:versionCode="090108161" android:versionName="1.8.16"> <!-- %%INSERT_PERMISSIONS --> <!-- %%INSERT_FEATURES --> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/> <application android:name="org.qtproject.qt.android.bindings.QtApplication" android:extractNativeLibs="true" android:hardwareAccelerated="true" android:label="myapp" android:requestLegacyExternalStorage="true" android:allowNativeHeapPointerTagging="false" android:icon="@drawable/icon"> <activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="myapp" android:launchMode="singleTop" android:screenOrientation="unspecified"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/> <meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/> <meta-data android:name="android.app.extract_android_style" android:value="none"/> </activity> </application> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> </manifest>
-
I am facing somewhat simmilar problem. I setup the -DQT_ANDROID_TARGET_SDK_VERSION:STRING=34.0.0 as the documentation says, I set the compilation buidltools for 34.0 yet the final manifest always list as 31.0.
I am a bit lost on how do I make the final maniefst show target SDK as 34.0 that is what google now requires!
-
Try recreating the AndroidManifest from the templates. IIRC It changed how Android target API is stored in the file, recreating the manifest fixed it for me
-
Try recreating the AndroidManifest from the templates. IIRC It changed how Android target API is stored in the file, recreating the manifest fixed it for me
@J-Hilk NOthing changes for me. WHy Qt Creator option of the target SDK is grayed out ? I cannot setup it there. Can anyone post me an example of a properly build manifest so I can manually write it in the xml?
I Grep searched for every single place the number 31 appeared in the project directory. THey appeared only in the BUILD directories. Replaced everything to 34, When I build the project QtCreator overwrittes it to 31.
-
I'm having trouble selecting the target API level. I used to do this on the AndroidManifest.xml, however, within the last year one of the QT updates caused those options to become un-editable (see below)
here are my build steps. I was hoping the "android build tools version" would cause it to target API level 34, but it appears to not be the case. According to play store, I am targeting API level 30 and I don't know where that's coming from.
here is my android environment, in case that helps. Also, I'm using QT creator v11.0.2 based on QT 6.4.3.
@kgregory https://developer.android.com/build/jdks
For SDK 34(this is for Android 14) you need JDK 17. But your JDK is 11. How can you set 34? They do not match. Android is a big mess.
Android Java API and language features supported 14 (API 34) 17 Core libraries 13 (API 33) 11 Core libraries 12 (API 32) 11 Java API 11 and lower Android versions
Pay attention to these numbers. Otherwise, your code may not work in Android as you expect.
-
J JoeCFD referenced this topic on
-
@kgregory https://developer.android.com/build/jdks
For SDK 34(this is for Android 14) you need JDK 17. But your JDK is 11. How can you set 34? They do not match. Android is a big mess.
Android Java API and language features supported 14 (API 34) 17 Core libraries 13 (API 33) 11 Core libraries 12 (API 32) 11 Java API 11 and lower Android versions
Pay attention to these numbers. Otherwise, your code may not work in Android as you expect.
@JoeCFD That helps, I think we are on to something here. I'm still getting errors though. The constant thing I keep finding when I search on the errors I'm getting seems to be pointing at my gradle being the wrong version to go with my SDK and/or JDK.
I'm not really sure where gradle is, but I found in my project folder android/graddle/wrapper/gradle-wrapper.properties, there is a line that says
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
. One of the guides I found was from 2020 and said that for JDK 14, as of that date, I should be usinggradle-6.3-bin.zip
. Any idea what I should be using for JDK-17 and SDK-34? I tried the latest (8.3) and still get errors.That table was helpful, it appears I can build successfully for API-31, which technically meets the play store requirements right now. I was hoping to future proof the app a bit more by targeting API-34, though.
-
@JoeCFD That helps, I think we are on to something here. I'm still getting errors though. The constant thing I keep finding when I search on the errors I'm getting seems to be pointing at my gradle being the wrong version to go with my SDK and/or JDK.
I'm not really sure where gradle is, but I found in my project folder android/graddle/wrapper/gradle-wrapper.properties, there is a line that says
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
. One of the guides I found was from 2020 and said that for JDK 14, as of that date, I should be usinggradle-6.3-bin.zip
. Any idea what I should be using for JDK-17 and SDK-34? I tried the latest (8.3) and still get errors.That table was helpful, it appears I can build successfully for API-31, which technically meets the play store requirements right now. I was hoping to future proof the app a bit more by targeting API-34, though.
@kgregory
Gradle for building application packages (APK) and app bundles (AAB) for Android devices. Gradle is delivered with Qt 5.9, and later.
from
https://doc.qt.io/qt-5/android-getting-started.htmlIn Linux, you can use command
locate gradle
to find the versions of gradle you are using and check out any mismatch.
I guess you can change the gradle version in Qt as well. I did it once. -
@kgregory
Gradle for building application packages (APK) and app bundles (AAB) for Android devices. Gradle is delivered with Qt 5.9, and later.
from
https://doc.qt.io/qt-5/android-getting-started.htmlIn Linux, you can use command
locate gradle
to find the versions of gradle you are using and check out any mismatch.
I guess you can change the gradle version in Qt as well. I did it once.@JoeCFD sorry if I'm being daft, but is there an equivalent command on windows? I just don't see any options anywhere in QT to set the gradle version (except that gradle-wrapper.properties file, which in the project). If gradle is already installed on my machine, then I have no idea where it is or how I would go about updating it.
I did do a full re-install of Qt the other day, but that hasn't changed anything for me. I don't believe it re-installed some of these build environment pieces or user settings, though. So it might be foolish for me to think that a re-install would have solved the issue. In any case, I'm simply at a loss to figure out where to go to fix gradle.
-
@JoeCFD sorry if I'm being daft, but is there an equivalent command on windows? I just don't see any options anywhere in QT to set the gradle version (except that gradle-wrapper.properties file, which in the project). If gradle is already installed on my machine, then I have no idea where it is or how I would go about updating it.
I did do a full re-install of Qt the other day, but that hasn't changed anything for me. I don't believe it re-installed some of these build environment pieces or user settings, though. So it might be foolish for me to think that a re-install would have solved the issue. In any case, I'm simply at a loss to figure out where to go to fix gradle.
-