Important: Please read the Qt Code of Conduct -

How can I put extra files into my android bundle?

  • In my code there is a line to load an extra binary file in to my APP, looks as the following:

    QFileInfo graph_binary("./Models/graph_binary.pb");

    This file is loaded for a 3rd lib, so I can not use the qrc file management.

    How can I load this file into my Android APP?

    The correspond config for Macs:

    APP_PB_FILES.files = $$PWD/Models/graph_binary.pb
    APP_PB_FILES.path = Contents/MacOS/Models

    For iOS:

    APP_PB_FILES.files = $$PWD/Models/graph_binary.pb
    APP_PB_FILES.path = Models

  • Lifetime Qt Champion


    You need to use the correct path to your data. Currently you're using a relative path to your application binary which won't be valid e.g. on iOS.

  • @SGaist Thank you for your suggestion, could you show me an example how to correctly set and reference the pathway?

  • Lifetime Qt Champion

    You have for example QStandardPaths.

  • @SGaist Thank you for your information. But here my problem is how to put an extra file into the android bundle in the .pro file, Could you also give a configuration example?

  • @LeoChen

    In your case, it is better to use the Android assets file system(read only).
    Like this:

    APP_PB_FILES.files = $$PWD/Models/graph_binary.pb
    APP_PB_FILES.path = /assets/Models

    Then you can access to the data installed using the "assets:/Models/graph_binary.pb".

  • @Devopia53 said in How can I put extra files into my android bundle?:


    Thank you for your suggestion. In this way, I have successfully copy the file into the assets folder. However, since I am going to use a 3rd lib to load that file instead of QtCore lib, I get "Not found: assets:/Models/graph_binary.pb".

    Is there a correspond mechanism in Qt as in use of assetManager on Android?

  • @LeoChen

    Yes. This feature is similar to Android. Here

  • Well, I kind of give up and use an ugly yet worked method:

        QString file_location = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
        QDir t_dir(file_location);
        if (!t_dir.exists()) {
        auto t_copy = QFile::copy(":/Models/graph_binary.pb", file_location + "/graph_binary.pb");

    Then reference the file from the 3rd lib.

Log in to reply