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.
  • Gianluca BernardiG Offline
    Gianluca BernardiG Offline
    Gianluca Bernardi
    wrote on last edited by Gianluca Bernardi
    #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
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #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
      • Gianluca BernardiG Offline
        Gianluca BernardiG Offline
        Gianluca Bernardi
        wrote on 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
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          show some of your code.

          1 Reply Last reply
          0
          • Gianluca BernardiG Offline
            Gianluca BernardiG Offline
            Gianluca Bernardi
            wrote on 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.

            JoeCFDJ 1 Reply Last reply
            0
            • Gianluca BernardiG Gianluca Bernardi

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

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

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

              1 Reply Last reply
              0
              • Gianluca BernardiG Offline
                Gianluca BernardiG Offline
                Gianluca Bernardi
                wrote on 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!

                JoeCFDJ 1 Reply Last reply
                0
                • Gianluca BernardiG Gianluca Bernardi

                  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!

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on 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

                  • Login

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