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. [Qt on Android] App doesn't start when i set specific defaultConfig on build.gradle file
QtWS25 Last Chance

[Qt on Android] App doesn't start when i set specific defaultConfig on build.gradle file

Scheduled Pinned Locked Moved Solved Mobile and Embedded
androidqt creatorgradleapi 31c++
8 Posts 2 Posters 1.9k 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.
  • G Offline
    G Offline
    Gianluca Bernardi
    wrote on 9 Dec 2022, 07:37 last edited by Gianluca Bernardi 12 Sept 2022, 09:05
    #1

    Goodmorning all,
    I've been stuck in this problem for a long time now and can't get out of it.
    I'm using Qt Creator 9.0.0 with kits (tried with these 4): Android Qt 5.12.2 Clang arm64-v8a, Android Qt 5.12.12 Clang arm64-v8a, Android Qt 5.13.0 Clang arm64-v8a, Android Qt 5.13.2 Clang arm64-v8a.
    These are the Android/Gradle settings:

    gradle.properties

    androidBuildToolsVersion=31.0.0
    androidCompileSdkVersion=31
    buildDir=build
    qt5AndroidDir=C:/Qt/5.13.2/android_arm64_v8a/src/android/java
    org.gradle.java.home=C:/JDK/jdk-19+36
    android.useAndroidX=true
    

    build.gradle

    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:7.3.1'
        }
    }
    

    gradle-wrapper.properties

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    

    The problem is the following:
    By compiling the app with these 4 kits, without setting any defaultConfig in the build.gradle file, the app starts correctly and I can use it, but, when I load it into the Google Play Console to release it, I get this message:
    Your app's current target API level is 1, but the minimum target API level should be 31 to ensure your app is based on the latest APIs optimized for security and good performance. Change the target API level of your app to at least 31.
    Although in the AndroidManifest.xml file I have the following settings:

    Cattura.PNG

    So I deduced that the AndroidManifest.xml file is being ignored...
    So I tried to set minSdkVersion and targetSdkVersion in the build.gradle file but this way, when I start the app, it gets stuck with black screen and can't be used, or it opens but shortly after starting it crashes (after 5 seconds).

        defaultConfig {
            minSdkVersion 26
            targetSdkVersion 31
        }
    

    Can someone help me?
    Thansk a lot

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JoeCFD
      wrote on 9 Dec 2022, 14:40 last edited by JoeCFD 12 Sept 2022, 14:45
      #2

      Your JDK is 19. I guess JDK 11 is the one you need. You are not using 5.12.12. Your Qt version is 5.13.2. Try 5.15.2 or above.
      Your gradle versions have mismatch as well:
      classpath 'com.android.tools.build:gradle:7.3.1'
      distributionUrl=https://services.gradle.org/distributions/gradle-7.6-all.zip

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Gianluca Bernardi
        wrote on 9 Dec 2022, 17:08 last edited by
        #3

        Thank you for the reply!

        I did what you told me, so i set JDK to 11 and tried to compile with Android Qt 5.15.2 Kit Clang Multi-Abi.
        The app compiles correctly, but, once started, a black screen still appears, moreover I noticed that the APK weight is 50MB, while if I run it all again by removing the defaultConfig settings below:

           defaultConfig {
                minSdkVersion 26
                targetSdkVersion 31
            }
        

        I get the same result but weight of the APK is 24MB.
        I haven't changed Gradle versions, how do I know which versions are the correct ones?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JoeCFD
          wrote on 9 Dec 2022, 17:22 last edited by
          #4

          show some of your code.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Gianluca Bernardi
            wrote on 13 Dec 2022, 07:20 last edited by
            #5

            What parts of the code do you want to see? There are many files, I don't know where to start.

            J 1 Reply Last reply 13 Dec 2022, 14:53
            0
            • G Gianluca Bernardi
              13 Dec 2022, 07:20

              What parts of the code do you want to see? There are many files, I don't know where to start.

              J Offline
              J Offline
              JoeCFD
              wrote on 13 Dec 2022, 14:53 last edited by
              #6

              @Gianluca-Bernardi Try a simple case with main window with a toolbar.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Gianluca Bernardi
                wrote on 15 Dec 2022, 15:16 last edited by
                #7

                I managed to solve the problem!
                I didn't understand why, but, by changing this setting on AndroidManifest.xml

                Cattura2.PNG

                to

                default.PNG

                the application no longer gets stuck on the black screen and no longer crashes after launch.

                Thank you @JoeCFD for the help!

                J 1 Reply Last reply 15 Dec 2022, 17:00
                0
                • G Gianluca Bernardi
                  15 Dec 2022, 15:16

                  I managed to solve the problem!
                  I didn't understand why, but, by changing this setting on AndroidManifest.xml

                  Cattura2.PNG

                  to

                  default.PNG

                  the application no longer gets stuck on the black screen and no longer crashes after launch.

                  Thank you @JoeCFD for the help!

                  J Offline
                  J Offline
                  JoeCFD
                  wrote on 15 Dec 2022, 17:00 last edited by
                  #8

                  @Gianluca-Bernardi I have default as well. Not sure how you got full before. Good to know you solved the issue.

                  1 Reply Last reply
                  1

                  7/8

                  15 Dec 2022, 15:16

                  • Login

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