Unsolved Android deployment... how to deploy images for app to load
-
Hi.
I have a QtQuick app that loads an image from disk and displays it.
On the desktop, no problem deploying. I have an "images" directory in the same directory as the exe and I use the source "file:./images/myimage.png" and all is well.
But I can't deploy to Android. I have tried to add a "drawable" directory to the "res" directory with my image in it but it keeps getting deleted and reset when I go to deploy.
What's the secret? Do I need to adjust AndroidManifest.xml? Do I need to add something to the .pro file?
And will my app be able to load the image by making an Image.source = "file:./res/drawable/myimage.png"??
Again, very simple QtQuick, as the following qml shows:
Window { visible: true width: 640 height: 480 title: qsTr("Test Android") Rectangle { id: mainRect anchors.fill: parent color: "blue" Image { id: mainImage anchors.centerIn: mainRect width: mainRect.width * 0.5 source: "file:./drawable/myimage.png" fillMode: Image.PreserveAspectFit } } }
Please help!
Thanks.
-
Hi, use qrc files for images. Add your stuff to qrc file then it will be compiled and deployed. http://doc.qt.io/qt-5/resources.html
-
@morte Thanks for that but I do not want to compile the images into the executable any more. You see I had already done this, adding many, many images to the qrc, and, eventually, when it got too big, the compiler ran out of heap space. It's better if I can just load the images from disk at runtime.
-
@dogbear said in Android deployment... how to deploy images for app to load:
It's better if I can just load the images from disk at runtime.
and much slower.
Anyway you can add the images to the assets folder and access them (even out of QML iirc) with an asset:// url
https://community.kde.org/Necessitas/Assets
The assets folder can be found in the path you specified via ANDROID_PACKAGE_SOURCE_DIR qmake variable