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 6.3 Build Android App Failed
Forum Updated to NodeBB v4.3 + New Features

Qt 6.3 Build Android App Failed

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 3.2k 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
    Gary Cui
    wrote on last edited by Gary Cui
    #1

    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 errors

    FAILURE: 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
    屏幕截图 2022-08-23 233230.png

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gary Cui
      wrote on last edited by
      #3

      @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

      Reason see: https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted

      %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
      
      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #2

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gary Cui
          wrote on last edited by
          #3

          @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

          Reason see: https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted

          %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
          
          1 Reply Last reply
          0
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #4

            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.

            G 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              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.

              G Offline
              G Offline
              Gary Cui
              wrote on last edited by Gary Cui
              #5

              @JoeCFD step 1 seems to download android construct file, the construct file version is 4.2.2, it's depdence on gradle binary 6.7.1(step 2). I had built an app successfully, thanks again.

              1 Reply Last reply
              0
              • JoeCFDJ JoeCFD referenced this topic on

              • Login

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