Qt 6.3 Build Android App Failed
-
I created an easy swipe app with Qt6.3. I built successfully against Device-LocalPC, but failed against Android(arm64-v8a)
I compiled it, got errorsFAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':checkDebugAarMetadata'. > Could not resolve all dependencies for configuration ':debugRuntimeClasspath'. > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. * Try: > Run with --stacktrace option to get the stack trace. > Run with --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings
the error seems gradle construct failed
file build.gradle
buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.0.2' } } repositories { google() mavenCentral() } apply plugin: 'com.android.application' dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) } android { /******************************************************* * The following variables: * - androidBuildToolsVersion, * - androidCompileSdkVersion * - qtAndroidDir - holds the path to qt android files * needed to build any Qt application * on Android. * * are defined in gradle.properties file. This file is * updated by QtCreator and androiddeployqt tools. * Changing them manually might break the compilation! *******************************************************/ compileSdkVersion androidCompileSdkVersion.toInteger() buildToolsVersion androidBuildToolsVersion ndkVersion androidNdkVersion // Extract native libraries from the APK packagingOptions.jniLibs.useLegacyPackaging true sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = [qtAndroidDir + '/src', 'src', 'java'] aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl'] res.srcDirs = [qtAndroidDir + '/res', 'res'] resources.srcDirs = ['resources'] renderscript.srcDirs = ['src'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] } } tasks.withType(JavaCompile) { options.incremental = true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } lintOptions { abortOnError false } // Do not compress Qt binary resources file aaptOptions { noCompress 'rcc' } defaultConfig { resConfig "en" minSdkVersion qtMinSdkVersion targetSdkVersion qtTargetSdkVersion ndk.abiFilters = qtTargetAbiList.split(",") } }
file gradle.properties
# Project-wide Gradle settings. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2500m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # Enable building projects in parallel org.gradle.parallel=true # Gradle caching allows reusing the build artifacts from a previous # build with the same inputs. However, over time, the cache size will # grow. Uncomment the following line to enable it. #org.gradle.caching=true android.bundle.enableUncompressedNativeLibs=false androidBuildToolsVersion=31.0.0 androidCompileSdkVersion=31 androidNdkVersion=22.1.7171670 buildDir=build qt5AndroidDir=D:/Qt/6.3.1/android_arm64_v8a/src/android/java qtAndroidDir=D:/Qt/6.3.1/android_arm64_v8a/src/android/java qtMinSdkVersion=23 qtTargetAbiList=arm64-v8a qtTargetSdkVersion=30
Version infos
OS: win11 perofession QtCreator: Qt Creator 8.0.1-Based on Qt 6.3.1 (MSVC 2019, x86_64) (Community) Qt: Qt6.3.1 JavaJDK: jdk-11.0.11.9-hotspot AndroidSDK: 7.0 NDKVersion: 22.1.7171670
OtherAndroidVersion
-
@JoeCFD Thanks for you reply.
It seems that android construct file 7.0.2 has some bug for android-SDK 7.0, I change android-gradle:7.0.2 to 4.2.2, it works.
I modify three steps to make it work.
Step 1:Qt\6.3.1\android_arm64_v8a\src\android\templates\build.gradle
# support version ref: https://maven.google.com/web/index.html#com.android.tools.build:gradle #line 7, change gradle:7.0.2=>gradle:4.2.2 classpath 'com.android.tools.build:gradle:4.2.2'
Step 2:
Qt\6.3.1\android_arm64_v8a\src\3rdparty\gradle\gradle\wrapper\gradle-wrapper.properties
# line 3, gradle-7.4-bin.zip => gradle-6.7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Step 3: Change Android SDK build-tools/31.0.0 filenames of d8.bat, d8.jar
%AppData%\Local\Android\Sdk\build-tools\31.0.0\d8.bat => dx.bat %AppData%\Local\Android\Sdk\build-tools\31.0.0\lib\d8.jar => dx.jar
-
https://docs.gradle.org/current/userguide/compatibility.html
for jdk-11, the first gradle version is 5.0. Maybe you can try lower version of gradle.
You can change gradle version in qt here:
Qt/5.15.2/android/src/3rdparty/gradle/gradle/wrapper/gradle-wrapper.properties
default version is 5.6.4 in 5.15.2. Check yours out. -
@JoeCFD Thanks for you reply.
It seems that android construct file 7.0.2 has some bug for android-SDK 7.0, I change android-gradle:7.0.2 to 4.2.2, it works.
I modify three steps to make it work.
Step 1:Qt\6.3.1\android_arm64_v8a\src\android\templates\build.gradle
# support version ref: https://maven.google.com/web/index.html#com.android.tools.build:gradle #line 7, change gradle:7.0.2=>gradle:4.2.2 classpath 'com.android.tools.build:gradle:4.2.2'
Step 2:
Qt\6.3.1\android_arm64_v8a\src\3rdparty\gradle\gradle\wrapper\gradle-wrapper.properties
# line 3, gradle-7.4-bin.zip => gradle-6.7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Step 3: Change Android SDK build-tools/31.0.0 filenames of d8.bat, d8.jar
%AppData%\Local\Android\Sdk\build-tools\31.0.0\d8.bat => dx.bat %AppData%\Local\Android\Sdk\build-tools\31.0.0\lib\d8.jar => dx.jar
-
Are you sure you did it right? In step 2, you set gradle-7.4-bin.zip => gradle-6.7.1-bin.zip and gradle 6.7.1 will be installed. But you set the build.gradle to 4.2.2 in Step 1.
Be aware that there could more dirs in Qt\6.3.1\ like
Qt\6.3.1\android_arm64_v8a
Qt\6.3.1\android_armeabi_v7a
Qt\6.3.1\android_x86
Qt\6.3.1\android_x86_64
all of them may have build.gradle files. If yes, change all of them. Qt5 has only one dir. -
Are you sure you did it right? In step 2, you set gradle-7.4-bin.zip => gradle-6.7.1-bin.zip and gradle 6.7.1 will be installed. But you set the build.gradle to 4.2.2 in Step 1.
Be aware that there could more dirs in Qt\6.3.1\ like
Qt\6.3.1\android_arm64_v8a
Qt\6.3.1\android_armeabi_v7a
Qt\6.3.1\android_x86
Qt\6.3.1\android_x86_64
all of them may have build.gradle files. If yes, change all of them. Qt5 has only one dir. -
J JoeCFD referenced this topic on