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
Forum Updated to NodeBB v4.3 + New Features

Adding Assets To Android Build Using CMake

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 982 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.
  • KenAppleby 0K Offline
    KenAppleby 0K Offline
    KenAppleby 0
    wrote on 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?

    jsulmJ 1 Reply Last reply
    0
    • KenAppleby 0K KenAppleby 0

      @jsulm That page makes no mention of android assets.

      MesrineM Offline
      MesrineM Offline
      Mesrine
      wrote on 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

      KenAppleby 0K 1 Reply Last reply
      2
      • KenAppleby 0K KenAppleby 0

        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?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on 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

        KenAppleby 0K 1 Reply Last reply
        0
        • jsulmJ jsulm

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

          KenAppleby 0K Offline
          KenAppleby 0K Offline
          KenAppleby 0
          wrote on last edited by
          #3

          @jsulm That page makes no mention of android assets.

          MesrineM 1 Reply Last reply
          0
          • KenAppleby 0K KenAppleby 0

            @jsulm That page makes no mention of android assets.

            MesrineM Offline
            MesrineM Offline
            Mesrine
            wrote on 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

            KenAppleby 0K 1 Reply Last reply
            2
            • MesrineM Mesrine

              @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

              KenAppleby 0K Offline
              KenAppleby 0K Offline
              KenAppleby 0
              wrote on last edited by
              #5

              @Mesrine Excellent! Thanks.

              1 Reply Last reply
              0
              • KenAppleby 0K KenAppleby 0 has marked this topic as solved on

              • Login

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