Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. how to select android target API level?
Forum Updated to NodeBB v4.3 + New Features

how to select android target API level?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
13 Posts 5 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JKSHJ Offline
    JKSHJ Offline
    JKSH
    Moderators
    wrote on last edited by
    #2

    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

    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

    K 1 Reply Last reply
    0
    • JKSHJ JKSH

      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

      K Offline
      K Offline
      kgregory
      wrote on last edited by kgregory
      #3

      @JKSH hmm, now I get this

      a50b10ff-410e-4662-a375-78628d3ec7c2-image.png

      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>
      
      1 Reply Last reply
      0
      • T Offline
        T Offline
        TiagoSD
        wrote on last edited by
        #4

        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!

        1 Reply Last reply
        0
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #5

          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


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          T 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            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

            T Offline
            T Offline
            TiagoSD
            wrote on last edited by TiagoSD
            #6

            @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.

            1 Reply Last reply
            0
            • K kgregory

              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)

              45a536c1-fab9-4d02-884f-62471b847d46-image.png

              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.
              37249c8d-de10-4712-8599-245065bbf350-image.png
              d91a2a99-044e-42fe-add8-2e22a7e5bbb1-image.png

              here is my android environment, in case that helps. Also, I'm using QT creator v11.0.2 based on QT 6.4.3.
              f376bfad-e1a9-414a-bd21-e1c90cf6a8bb-image.png

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #7

              @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.

              K 1 Reply Last reply
              2
              • JoeCFDJ JoeCFD referenced this topic on
              • JoeCFDJ JoeCFD

                @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.

                K Offline
                K Offline
                kgregory
                wrote on last edited by kgregory
                #8

                @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 using gradle-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.

                JoeCFDJ 1 Reply Last reply
                0
                • K kgregory

                  @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 using gradle-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.

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by
                  #9

                  @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.html

                  In 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.

                  K 1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @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.html

                    In 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.

                    K Offline
                    K Offline
                    kgregory
                    wrote on last edited by
                    #10

                    @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.

                    JoeCFDJ 1 Reply Last reply
                    0
                    • K kgregory

                      @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.

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by
                      #11

                      @kgregory https://docs.gradle.org/current/userguide/compatibility.html
                      https://forum.qt.io/topic/138810/qt-6-3-build-android-app-failed/2

                      K 1 Reply Last reply
                      1
                      • JoeCFDJ JoeCFD

                        @kgregory https://docs.gradle.org/current/userguide/compatibility.html
                        https://forum.qt.io/topic/138810/qt-6-3-build-android-app-failed/2

                        K Offline
                        K Offline
                        kgregory
                        wrote on last edited by kgregory
                        #12
                        This post is deleted!
                        K 1 Reply Last reply
                        0
                        • K kgregory

                          This post is deleted!

                          K Offline
                          K Offline
                          kgregory
                          wrote on last edited by kgregory
                          #13
                          This post is deleted!
                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved