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. How to switch from ant to gradle while qmake building command line or in a shell script
Forum Update on Tuesday, May 27th 2025

How to switch from ant to gradle while qmake building command line or in a shell script

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 3.7k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    Nelson_Piquet
    wrote on 29 Sept 2016, 14:35 last edited by
    #1

    I use following in a shell script for building android apk from my Qt app. Following is the crux of it.

    export ANDROID_SDK_ROOT=/path/To/AndroidSdk
    export ANDROID_NDK_ROOT=/path/To/AndroidNdk
    export ANT_HOME=/path/To/Ant
    export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANT_HOME/bin:$JAVA_HOME/bin

    qmake MyQtApp.pro -spec android-g++ CONFIG+=qtquickcompiler CONFIG+=$release
    make
    make install INSTALL_ROOT=/path/to/some/folder
    $androiddeployqt --sign MyKey.keystore gevupc --storepass somePassword --output android --verbose --input android-libMyQtApp.so-deployment-settings.json

    This is of course using ant. How can I switch qmake to use gradle instead of ant ? WIth gradle I want to support auto-incremental versioning of the app

    B 1 Reply Last reply 29 Sept 2016, 15:09
    1
    • N Nelson_Piquet
      29 Sept 2016, 14:35

      I use following in a shell script for building android apk from my Qt app. Following is the crux of it.

      export ANDROID_SDK_ROOT=/path/To/AndroidSdk
      export ANDROID_NDK_ROOT=/path/To/AndroidNdk
      export ANT_HOME=/path/To/Ant
      export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANT_HOME/bin:$JAVA_HOME/bin

      qmake MyQtApp.pro -spec android-g++ CONFIG+=qtquickcompiler CONFIG+=$release
      make
      make install INSTALL_ROOT=/path/to/some/folder
      $androiddeployqt --sign MyKey.keystore gevupc --storepass somePassword --output android --verbose --input android-libMyQtApp.so-deployment-settings.json

      This is of course using ant. How can I switch qmake to use gradle instead of ant ? WIth gradle I want to support auto-incremental versioning of the app

      B Offline
      B Offline
      benlau
      Qt Champions 2016
      wrote on 29 Sept 2016, 15:09 last edited by
      #2

      @Nelson_Piquet You need to add "--gradle" to the androiddeployqt.

      An example is available at:
      https://github.com/benlau/qtci/blob/master/bin/build-android-gradle-project

      Moreover, in case you build apk by command line. You may consider to use this script to increase the version code:

      https://github.com/benlau/qtci#5-binincrease-android-version-code

      N 2 Replies Last reply 29 Sept 2016, 19:10
      2
      • B benlau
        29 Sept 2016, 15:09

        @Nelson_Piquet You need to add "--gradle" to the androiddeployqt.

        An example is available at:
        https://github.com/benlau/qtci/blob/master/bin/build-android-gradle-project

        Moreover, in case you build apk by command line. You may consider to use this script to increase the version code:

        https://github.com/benlau/qtci#5-binincrease-android-version-code

        N Offline
        N Offline
        Nelson_Piquet
        wrote on 29 Sept 2016, 19:10 last edited by
        #3

        @benlau thanks a lot. i will try that

        1 Reply Last reply
        0
        • N Offline
          N Offline
          Nelson_Piquet
          wrote on 10 Oct 2016, 17:02 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • B benlau
            29 Sept 2016, 15:09

            @Nelson_Piquet You need to add "--gradle" to the androiddeployqt.

            An example is available at:
            https://github.com/benlau/qtci/blob/master/bin/build-android-gradle-project

            Moreover, in case you build apk by command line. You may consider to use this script to increase the version code:

            https://github.com/benlau/qtci#5-binincrease-android-version-code

            N Offline
            N Offline
            Nelson_Piquet
            wrote on 11 Oct 2016, 18:43 last edited by
            #5

            @benlau Sorry to come back to this after a gap. I dont see a build.gradle file in your project. Is that not required ? adding --gradle kicks in gradle but it gives the follwoing error. Isnt there a sample qt project building with gradle that I can see ? there must be so many

            Getting following error with gradle :

            A problem occurred configuring root project 'android-build'.

            Could not resolve all dependencies for configuration ':classpath'.
            Could not resolve com.android.tools.build:gradle:1.1.0.
            Required by:
            :android-build:unspecified
            Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.1.0/gradle-1.1.0.pom'.
            jcenter.bintray.com: unknown error

            B 1 Reply Last reply 21 Oct 2016, 13:27
            0
            • N Nelson_Piquet
              11 Oct 2016, 18:43

              @benlau Sorry to come back to this after a gap. I dont see a build.gradle file in your project. Is that not required ? adding --gradle kicks in gradle but it gives the follwoing error. Isnt there a sample qt project building with gradle that I can see ? there must be so many

              Getting following error with gradle :

              A problem occurred configuring root project 'android-build'.

              Could not resolve all dependencies for configuration ':classpath'.
              Could not resolve com.android.tools.build:gradle:1.1.0.
              Required by:
              :android-build:unspecified
              Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.1.0/gradle-1.1.0.pom'.
              jcenter.bintray.com: unknown error

              B Offline
              B Offline
              benlau
              Qt Champions 2016
              wrote on 21 Oct 2016, 13:27 last edited by
              #6

              @Nelson_Piquet My link is an example script to show how to build androiddeployqt with gradle.

              androiddeployqt --input $JSON --output `pwd`/android-build --deployment bundled --android-platform android-18 --gradle --no-gdbserver $DEPLOY_ARGS
              

              I don't know how to solve your problem but you may try this example project:

              (DEV branch)
              https://github.com/benlau/quickandroid/tree/DEV/examples/quickandroidexample

              1 Reply Last reply
              0

              • Login

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