[Qt on Android] App doesn't start when i set specific defaultConfig on build.gradle file
-
wrote on 9 Dec 2022, 07:37 last edited by Gianluca Bernardi 12 Sept 2022, 09:05
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: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 -
wrote on 9 Dec 2022, 14:40 last edited by JoeCFD 12 Sept 2022, 14:45
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 -
wrote on 9 Dec 2022, 17:08 last edited by
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? -
wrote on 9 Dec 2022, 17:22 last edited by
show some of your code.
-
wrote on 13 Dec 2022, 07:20 last edited by
What parts of the code do you want to see? There are many files, I don't know where to start.
-
What parts of the code do you want to see? There are many files, I don't know where to start.
wrote on 13 Dec 2022, 14:53 last edited by@Gianluca-Bernardi Try a simple case with main window with a toolbar.
-
wrote on 15 Dec 2022, 15:16 last edited by
I managed to solve the problem!
I didn't understand why, but, by changing this setting on AndroidManifest.xmlto
the application no longer gets stuck on the black screen and no longer crashes after launch.
Thank you @JoeCFD for the help!
-
I managed to solve the problem!
I didn't understand why, but, by changing this setting on AndroidManifest.xmlto
the application no longer gets stuck on the black screen and no longer crashes after launch.
Thank you @JoeCFD for the help!
wrote on 15 Dec 2022, 17:00 last edited by@Gianluca-Bernardi I have default as well. Not sure how you got full before. Good to know you solved the issue.
7/8