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. Adding Assets To Android Build Using CMake

Adding Assets To Android Build Using CMake

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 965 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.
  • K Offline
    K Offline
    KenAppleby 0
    wrote on 20 Sept 2023, 08:15 last edited by
    #1

    I am using CMake to build an android application and want to add a plain .ini file to the assets folder, then access it from C++.

    This page in the Qt6 documentation describes only the qmake .pro file way to do this.

    What would be the correct way to do this using CMake?

    J 1 Reply Last reply 20 Sept 2023, 08:23
    0
    • K KenAppleby 0
      20 Sept 2023, 08:27

      @jsulm That page makes no mention of android assets.

      M Offline
      M Offline
      Mesrine
      wrote on 27 Sept 2023, 05:15 last edited by Mesrine
      #4

      @KenAppleby-0
      https://doc.qt.io/qt-6/android-platform-notes.html#assets-file-system

      It seems you can set QT_ANDROID_PACKAGE_SOURCE_DIR variable and add the folder assets. Then according to this Edit this

      The path specified by this variable can contain custom Java classes under src directory. By default, the androiddeployqt tool copies the application template from the Qt for Android installation path into your project's build directory, then it copies the contents of the path specified by this variable on top of that, overwriting any existing files. For instance, you can make a custom AndroidManifest.xml for your application, then place this directly into the directory specified by this variable.

      In CMake add

      set_property(TARGET yourtarget PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
      

      And put your assets folder under ${CMAKE_CURRENT_SOURCE_DIR}/android

      K 1 Reply Last reply 27 Sept 2023, 19:37
      2
      • K KenAppleby 0
        20 Sept 2023, 08:15

        I am using CMake to build an android application and want to add a plain .ini file to the assets folder, then access it from C++.

        This page in the Qt6 documentation describes only the qmake .pro file way to do this.

        What would be the correct way to do this using CMake?

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 20 Sept 2023, 08:23 last edited by
        #2

        @KenAppleby-0 See https://doc.qt.io/qt-6/resources.html

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        K 1 Reply Last reply 20 Sept 2023, 08:27
        0
        • J jsulm
          20 Sept 2023, 08:23

          @KenAppleby-0 See https://doc.qt.io/qt-6/resources.html

          K Offline
          K Offline
          KenAppleby 0
          wrote on 20 Sept 2023, 08:27 last edited by
          #3

          @jsulm That page makes no mention of android assets.

          M 1 Reply Last reply 27 Sept 2023, 05:15
          0
          • K KenAppleby 0
            20 Sept 2023, 08:27

            @jsulm That page makes no mention of android assets.

            M Offline
            M Offline
            Mesrine
            wrote on 27 Sept 2023, 05:15 last edited by Mesrine
            #4

            @KenAppleby-0
            https://doc.qt.io/qt-6/android-platform-notes.html#assets-file-system

            It seems you can set QT_ANDROID_PACKAGE_SOURCE_DIR variable and add the folder assets. Then according to this Edit this

            The path specified by this variable can contain custom Java classes under src directory. By default, the androiddeployqt tool copies the application template from the Qt for Android installation path into your project's build directory, then it copies the contents of the path specified by this variable on top of that, overwriting any existing files. For instance, you can make a custom AndroidManifest.xml for your application, then place this directly into the directory specified by this variable.

            In CMake add

            set_property(TARGET yourtarget PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
            

            And put your assets folder under ${CMAKE_CURRENT_SOURCE_DIR}/android

            K 1 Reply Last reply 27 Sept 2023, 19:37
            2
            • M Mesrine
              27 Sept 2023, 05:15

              @KenAppleby-0
              https://doc.qt.io/qt-6/android-platform-notes.html#assets-file-system

              It seems you can set QT_ANDROID_PACKAGE_SOURCE_DIR variable and add the folder assets. Then according to this Edit this

              The path specified by this variable can contain custom Java classes under src directory. By default, the androiddeployqt tool copies the application template from the Qt for Android installation path into your project's build directory, then it copies the contents of the path specified by this variable on top of that, overwriting any existing files. For instance, you can make a custom AndroidManifest.xml for your application, then place this directly into the directory specified by this variable.

              In CMake add

              set_property(TARGET yourtarget PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
              

              And put your assets folder under ${CMAKE_CURRENT_SOURCE_DIR}/android

              K Offline
              K Offline
              KenAppleby 0
              wrote on 27 Sept 2023, 19:37 last edited by
              #5

              @Mesrine Excellent! Thanks.

              1 Reply Last reply
              0
              • K KenAppleby 0 has marked this topic as solved on 27 Sept 2023, 19:47

              1/5

              20 Sept 2023, 08:15

              • Login

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