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 include C++ static libraries into the android apk of a QtApp, when building with Gradle
Forum Updated to NodeBB v4.3 + New Features

How to include C++ static libraries into the android apk of a QtApp, when building with Gradle

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
14 Posts 2 Posters 4.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.
  • raven-worxR raven-worx

    @Nelson_Piquet
    a static lib is already included into your binary at link time, otherwise you would already have an error there.
    So you should debug your crash using the debugger.

    N Offline
    N Offline
    Nelson_Piquet
    wrote on last edited by
    #3

    @raven-worx Good point. I will be glad if I don't have to do anything special for the static libs. I am looking through the logcat of my android device to analyze.

    Btw, following is the apk creation step in my build-script with --gradle, Is there anything wrong you see ?

    androiddeployqt --sign mykeystore myKeyalias --storepass myPassword --gradle clean build --output android --verbose --input android-libMyQtApp.so-deployment-settings.json

    Can I add something more to correct my build ? Is there anything wrong you see ?

    1 Reply Last reply
    0
    • raven-worxR raven-worx

      @Nelson_Piquet
      a static lib is already included into your binary at link time, otherwise you would already have an error there.
      So you should debug your crash using the debugger.

      N Offline
      N Offline
      Nelson_Piquet
      wrote on last edited by Nelson_Piquet
      #4

      @raven-worx My app is running all fine when built with ant. it started to crash only after building with gradle

      raven-worxR 1 Reply Last reply
      0
      • N Nelson_Piquet

        @raven-worx My app is running all fine when built with ant. it started to crash only after building with gradle

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #5

        @Nelson_Piquet
        check the catlog. Ther should be more info what exactly caused the crash and where.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        N 1 Reply Last reply
        1
        • raven-worxR raven-worx

          @Nelson_Piquet
          check the catlog. Ther should be more info what exactly caused the crash and where.

          N Offline
          N Offline
          Nelson_Piquet
          wrote on last edited by
          #6

          @raven-worx Following is the crash log I am getting:

          handle_notify_event, send msg [submit:trigger=0,bugtype=2,modulename=com.mycompany.myapp,level=1,testtype=NORMAL,path=/data/log/unzip/GRA-L09_GRA-L09C432B321a_0000000000_20161014165530_crash,mode=1;]
          10-14 16:55:30.825 3199 3436 I logserver: send_to_client, send to (9) res = 188
          10-14 16:55:30.844 3443 3462 W System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.huawei.lcagent.client.LogCollectManager.getUserType()' on a null object reference
          10-14 16:55:30.844 3443 3462 W System.err: at com.android.server.util.ReportTools.getUserType(ReportTools.java:86)
          10-14 16:55:30.844 3443 3462 W System.err: at com.android.server.util.ReportTools.isBetaUser(ReportTools.java:73)
          10-14 16:55:30.844 3443 3462 W System.err: at com.android.server.util.ReportTools.report(ReportTools.java:58)
          10-14 16:55:30.844 3443 3462 W System.err: at com.android.server.util.HwUserBehaviourRecord.appExitRecord(HwUserBehaviourRecord.java:65)
          10-14 16:55:30.844 3443 3462 W System.err: at com.android.server.am.ActivityManagerService$UiHandler.handleMessage(ActivityManagerService.java:1521)
          10-14 16:55:30.844 3443 3462 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
          10-14 16:55:30.844 3443 3462 W System.err: at android.os.Looper.loop(Looper.java:150)
          10-14 16:55:30.844 3443 3462 W System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
          10-14 16:55:30.844 3443 3462 W System.err: at com.android.server.ServiceThread.run(ServiceThread.java:46)
          10-14 16:55:30.844 3443 3462 E ReportTools: This is not beta user build

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Nelson_Piquet
            wrote on last edited by
            #7

            Checked the catlog in another android device with better logging. Following is the cause of the crash

            Caused by: java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.bindings.QtApplication" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-2/lib/arm, /data/app/com.mycompany.myapp-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

            Not sure what I am doing wrong here

            raven-worxR 1 Reply Last reply
            0
            • N Nelson_Piquet

              Checked the catlog in another android device with better logging. Following is the cause of the crash

              Caused by: java.lang.ClassNotFoundException: Didn't find class "org.qtproject.qt5.android.bindings.QtApplication" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-2/lib/arm, /data/app/com.mycompany.myapp-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

              Not sure what I am doing wrong here

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #8

              @Nelson_Piquet
              did you create the Android tempaltes (as described here) so that the android classes are also deployed?

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • N Offline
                N Offline
                Nelson_Piquet
                wrote on last edited by
                #9

                I have the Androidmanifest file & the res folder inside MyAppfolder/android with ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android in MyApp.pro set. However, I have to move the manifest file 6 res folder inside MyAppfolder/android/src/main for gradle to build without issues.

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  Nelson_Piquet
                  wrote on last edited by
                  #10

                  by the way, I am doing this build command line using the following install step

                  androiddeployqt --sign mykeystore.keystore myAlias --storepass myPassword --gradle clean build --output android --verbose --input android-libMyApp.so-deployment-settings.json

                  raven-worxR 1 Reply Last reply
                  0
                  • N Nelson_Piquet

                    by the way, I am doing this build command line using the following install step

                    androiddeployqt --sign mykeystore.keystore myAlias --storepass myPassword --gradle clean build --output android --verbose --input android-libMyApp.so-deployment-settings.json

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #11

                    @Nelson_Piquet
                    so you are not using QtCreator?

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    N 1 Reply Last reply
                    0
                    • raven-worxR raven-worx

                      @Nelson_Piquet
                      so you are not using QtCreator?

                      N Offline
                      N Offline
                      Nelson_Piquet
                      wrote on last edited by
                      #12

                      @raven-worx In my team all use QtCreator including me as well. But, we need to make a build-script for jenkins & Continious Integration.

                      The build-script builds successfully when built with ant that comes by default with androiddeployqt We need the android part to build using gradle. Hence, I have appended this --gradle to androiddeployqt command & trying to build this with gradle.

                      Again, the reason of trying to use gradle here is for versioning. If you google how to auto-increment version number of android app, then everybody suggests to do it with gradle. I dont know why ? Everybody suggest to move on to gradle in the android community specially. May be there are other reasons as well. At the moment I am just trying to build our QtApp using gradle

                      raven-worxR 1 Reply Last reply
                      0
                      • N Nelson_Piquet

                        @raven-worx In my team all use QtCreator including me as well. But, we need to make a build-script for jenkins & Continious Integration.

                        The build-script builds successfully when built with ant that comes by default with androiddeployqt We need the android part to build using gradle. Hence, I have appended this --gradle to androiddeployqt command & trying to build this with gradle.

                        Again, the reason of trying to use gradle here is for versioning. If you google how to auto-increment version number of android app, then everybody suggests to do it with gradle. I dont know why ? Everybody suggest to move on to gradle in the android community specially. May be there are other reasons as well. At the moment I am just trying to build our QtApp using gradle

                        raven-worxR Offline
                        raven-worxR Offline
                        raven-worx
                        Moderators
                        wrote on last edited by
                        #13

                        @Nelson_Piquet
                        IIRC Qtcreator shows the build command in the console during the build

                        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                        If you have a question please use the forum so others can benefit from the solution in the future

                        N 1 Reply Last reply
                        0
                        • raven-worxR raven-worx

                          @Nelson_Piquet
                          IIRC Qtcreator shows the build command in the console during the build

                          N Offline
                          N Offline
                          Nelson_Piquet
                          wrote on last edited by
                          #14

                          @raven-worx Yeah. I got that from the compile log of qtCreator. Thats really good about Qt. The command is correctly set now otherwise the build would not succeed. I think I am missing some dependency/plugin or something in build.gradle which is causing the following error & crashing the app on launch

                          "Didn't find class "org.qtproject.qt5.android.bindings.QtApplication" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-2/lib/arm, /data/app/com.mycompany.myapp-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]"

                          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