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. [Solved]Bundle big binary file into android apk
Forum Updated to NodeBB v4.3 + New Features

[Solved]Bundle big binary file into android apk

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 2 Posters 3.3k 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.
  • T Offline
    T Offline
    tham
    wrote on 2 Sept 2017, 13:27 last edited by tham 9 Jun 2017, 10:44
    #1

    Qt5.9.1
    os : win10 64bits

    How could I bundle a big binary file(over 20MB) into the apk and load it later from android device?Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 Sept 2017, 21:53 last edited by
      #2

      Hi,

      The Assets file system looks like what you want to use.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • T Offline
        T Offline
        tham
        wrote on 4 Sept 2017, 00:09 last edited by tham 9 Apr 2017, 07:10
        #3

        @SGaist
        I try two solutions, both of them fail

        project layout

        android
        extra_data
          --MobileNetSSD_deploy.caffemodel
          --MobileNetSSD_deploy.prototxt
        assets
          --Samples
            --MobileNetSSD_deploy.caffemodel
            --MobileNetSSD_deploy.prototxt
        logics
        main.cpp
        main.qml
        Page1.qml
        Page1Form.ui.qml
        part1.pro
        qml.qrc
        qtquickcontrols2.conf
        

        android studio: 2.3.3.3
        android api : 25(I want to pick a lower api, but cannot)
        Qt5.9.1
        os : win10 64bits

        Add following lines to .pro

        SAMPLES_INSTALL_PATH=/assets/Samples
        
        # - setup the 'make install' step
        SAMPLE_FILES += $${SAMPLES_INSTALL_PATH}/MobileNetSSD_deploy.caffemodel
        SAMPLE_FILES += $${SAMPLES_INSTALL_PATH}/MobileNetSSD_deploy.prototxt
        samples.path = $${SAMPLES_INSTALL_PATH}
        samples.files += $${SAMPLE_FILES}
        samples.depends += FORCE
        
        INSTALLS += samples
        
        folder_01.source = extra_data
        folder_01.target = extra_data
        DEPLOYMENTFOLDERS += folder_01
        

        None of them work, because the folder after build(without deploy) remain the same size with or without DEPLOYMENTFOLDERS or INSTALLS(extra files are bigger than 20MB)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Sept 2017, 11:47 last edited by
          #4

          From a quick look: SAMPLES_INSTALL_PATH is an absolute path so samples point to an invalid file list.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply 5 Sept 2017, 09:22
          0
          • S SGaist
            4 Sept 2017, 11:47

            From a quick look: SAMPLES_INSTALL_PATH is an absolute path so samples point to an invalid file list.

            T Offline
            T Offline
            tham
            wrote on 5 Sept 2017, 09:22 last edited by
            #5

            @SGaist I change it to

            SAMPLES_INSTALL_PATH=$$PWD/assets/Samples
            

            This time pop out error message

            17:21:00: Starting: "C:\Users\rrrr\Qt\3rdLibs\Qt\digia\Tools\mingw530_32\bin\mingw32-make.exe" "INSTALL_ROOT=C:\Users\rrrr\Qt\blogCodes2\cross_platform_dl\build-part3\android-build" install
            The filename, directory name, or volume label syntax is incorrect.
            Makefile:3015: recipe for target 'install_samples' failed
            mingw32-make: *** [install_samples] Error 1
            17:21:02: The process "C:\Users\rrrr\Qt\3rdLibs\Qt\digia\Tools\mingw530_32\bin\mingw32-make.exe" exited with code 2.
            Error while building/deploying project part3 (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.9.1 for Android armv7))
            When executing step "Copy application data"
            
            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 5 Sept 2017, 19:54 last edited by
              #6

              AFAICS, you are using the same path to list the files and for the target directory. You should separate both. There's no C: drive on Android devices.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tham
                wrote on 6 Sept 2017, 10:42 last edited by tham
                #7

                I found a way to do it

                1 : Click android folder(This folder will be created if you click the create template button on QtCreator)
                2 : Copy your assets folder into the android folder
                3 : Add following lines to you pro file

                ANDROID_PACKAGE_SOURCE_DIR = android
                DISTFILES += $$ANDROID_PACKAGE_SOURCE_DIR/assets
                

                4 : The file in your assets cannot is compressed and cannot access by another library like opencv, std::ifstream etc. You have two solutions to open them

                1 : Download your resources to your system the first time you run your program
                2 : change suffix of your files as mp3, this can prevent compression of your assets. After that, copy the assets to somewhere you can access for anohter library to read them(ex : opencv)

                1 Reply Last reply
                0

                1/7

                2 Sept 2017, 13:27

                • Login

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