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. Compile APK 33 Android
Qt 6.11 is out! See what's new in the release blog

Compile APK 33 Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 4 Posters 1.6k Views
  • 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.
  • R Offline
    R Offline
    RenanHm
    wrote on last edited by
    #1

    Good afternoon. Recently, Google Play is requiring that new APPs created or updated on its platform have at least API level 33.
    Well, when making this change in the project, the "requestPermissionsSync" function of the "QtAndroid" class to request access permissions no longer works.

    I use QT 5.14.2.

    Here is the function that no longer works:

    //---------------------------------------------------------------------
    bool System::requestStoragePermission() {
    #ifdef AndroidARM64
        using namespace QtAndroid;
        //SOPermission sop;
        QStringList permissions = {"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.INTERNET"};
        const QHash<QString, PermissionResult> results = requestPermissionsSync(permissions);
        auto ok = true;
        auto i = 0;
        while (ok && i< permissions.size()) {
            if (!results.contains(permissions[i]) || results[permissions[i]] == PermissionResult::Denied) {
                qCritical() << "Couldn't get permission: " << permissions[i];
                ok = false;
                --i;
            }
            ++i;
        }
        return ok;
    #else
        return true;
    #endif
    }
    
    

    Any solution?

    jsulmJ 1 Reply Last reply
    0
    • R RenanHm

      Good afternoon. Recently, Google Play is requiring that new APPs created or updated on its platform have at least API level 33.
      Well, when making this change in the project, the "requestPermissionsSync" function of the "QtAndroid" class to request access permissions no longer works.

      I use QT 5.14.2.

      Here is the function that no longer works:

      //---------------------------------------------------------------------
      bool System::requestStoragePermission() {
      #ifdef AndroidARM64
          using namespace QtAndroid;
          //SOPermission sop;
          QStringList permissions = {"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.INTERNET"};
          const QHash<QString, PermissionResult> results = requestPermissionsSync(permissions);
          auto ok = true;
          auto i = 0;
          while (ok && i< permissions.size()) {
              if (!results.contains(permissions[i]) || results[permissions[i]] == PermissionResult::Denied) {
                  qCritical() << "Couldn't get permission: " << permissions[i];
                  ok = false;
                  --i;
              }
              ++i;
          }
          return ok;
      #else
          return true;
      #endif
      }
      
      

      Any solution?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @RenanHm said in Compile APK 33 Android:

      no longer works

      What exactly does this mean?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      0
      • jsulmJ jsulm

        @RenanHm said in Compile APK 33 Android:

        no longer works

        What exactly does this mean?

        R Offline
        R Offline
        RenanHm
        wrote on last edited by
        #3

        @jsulm It doesn't show any error... but at runtime it no longer asks the user to give permission... and the function always returns false

        L 1 Reply Last reply
        0
        • R RenanHm

          @jsulm It doesn't show any error... but at runtime it no longer asks the user to give permission... and the function always returns false

          L Offline
          L Offline
          lemons
          wrote on last edited by lemons
          #4

          @RenanHm I would check the Android 13 notes. I think they finally removed WRITE_EXTERNAL_STORAGE entirely and READ_EXTERNAL_STORAGE was replaced with the scoped permissions [READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO].

          If your app really needs full storage access (e.g. a file explorer), you have to go through the dedicated guide for the MANAGE_EXTERNAL_STORAGE permission, but this can only be used with very specific apps.

          All "standard" apps must use scoped storage, and don't have access to the legacy permissions anymore. Therefore, you should use the scoped storage of your app (doesn't require any permissions), and use a file provider and intents for sharing files with the system.

          P.S.: I did the storage transition with API level 30 and my only use-case was generating a PDF file, storing it and open it with an installed PDF reader.

          R 1 Reply Last reply
          0
          • L lemons

            @RenanHm I would check the Android 13 notes. I think they finally removed WRITE_EXTERNAL_STORAGE entirely and READ_EXTERNAL_STORAGE was replaced with the scoped permissions [READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO].

            If your app really needs full storage access (e.g. a file explorer), you have to go through the dedicated guide for the MANAGE_EXTERNAL_STORAGE permission, but this can only be used with very specific apps.

            All "standard" apps must use scoped storage, and don't have access to the legacy permissions anymore. Therefore, you should use the scoped storage of your app (doesn't require any permissions), and use a file provider and intents for sharing files with the system.

            P.S.: I did the storage transition with API level 30 and my only use-case was generating a PDF file, storing it and open it with an installed PDF reader.

            R Offline
            R Offline
            RenanHm
            wrote on last edited by
            #5

            @lemons I performed the tests with the permissions "READ_MEDIA_IMAGES, READ_MEDIA_VIDEO" but unfortunately it didn't work on API 33.

            My APP is not a file manager. Basically I need to select a JPG image or TXT file stored on the Android device.
            Even API 31 was getting it. Now in API 33 I can't do it anymore. The above function no longer works on API 33 to request permissions.

            One way I managed to load the files in the APP is by placing the files inside the APP installation folder in "files", as shown in the image below.

            WhatsApp Image 2023-08-31 at 11.29.10.jpeg

            The problem is that for the end user it is very complicated to access and use this folder... it is not practical.
            It was necessary to install a special file management APP to locate and open the folder in question, as the native Android APPs cannot find it.. they are hidden.

            Any other solution?

            L 1 Reply Last reply
            0
            • R RenanHm

              @lemons I performed the tests with the permissions "READ_MEDIA_IMAGES, READ_MEDIA_VIDEO" but unfortunately it didn't work on API 33.

              My APP is not a file manager. Basically I need to select a JPG image or TXT file stored on the Android device.
              Even API 31 was getting it. Now in API 33 I can't do it anymore. The above function no longer works on API 33 to request permissions.

              One way I managed to load the files in the APP is by placing the files inside the APP installation folder in "files", as shown in the image below.

              WhatsApp Image 2023-08-31 at 11.29.10.jpeg

              The problem is that for the end user it is very complicated to access and use this folder... it is not practical.
              It was necessary to install a special file management APP to locate and open the folder in question, as the native Android APPs cannot find it.. they are hidden.

              Any other solution?

              L Offline
              L Offline
              lemons
              wrote on last edited by
              #6

              @RenanHm
              I can't really help you, as my use-case is the other way round only.
              I assume you have to dive into the Android documentation and re-write all logic for this feature.

              Maybe some else can provide more information.

              Note: You can request an extended deadline for the transition to API level 33 in the PlayStore, but this only buys you a few weeks.

              Here a few ideas:

              • You should be able to accept "incoming shares", so the user could share any file with your app, so you have direct access to the file.
              • Also, you should be able to register your app for opening specific file-types, so your app will be present in the "app chooser", as long as the user hasn't set a default app for a certain file-type.
              • If you are not bound to the file-type, you could try to define your own file-type to avoid default apps being set. (e.g. ".txt" -> ".armazptxt").
                -> I don't know if Android allows this
              R 1 Reply Last reply
              0
              • L lemons

                @RenanHm
                I can't really help you, as my use-case is the other way round only.
                I assume you have to dive into the Android documentation and re-write all logic for this feature.

                Maybe some else can provide more information.

                Note: You can request an extended deadline for the transition to API level 33 in the PlayStore, but this only buys you a few weeks.

                Here a few ideas:

                • You should be able to accept "incoming shares", so the user could share any file with your app, so you have direct access to the file.
                • Also, you should be able to register your app for opening specific file-types, so your app will be present in the "app chooser", as long as the user hasn't set a default app for a certain file-type.
                • If you are not bound to the file-type, you could try to define your own file-type to avoid default apps being set. (e.g. ".txt" -> ".armazptxt").
                  -> I don't know if Android allows this
                R Offline
                R Offline
                RenanHm
                wrote on last edited by
                #7

                @lemons Thank you for your attention.

                About your idea of ​​"incoming shares". Do you have an example in QT of how this works?

                Because I see that QT can't seem to keep up with Android updates.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sahilverma
                  Banned
                  wrote on last edited by
                  #8
                  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