Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Can't view a png image on android



  • I'm developing an android app and the images can't get loaded to my device. I have the needed sprites and photos in the assets folder but can only use them on the desktop live client.

    On the console debugger I have this message:

    assets:/qml/NewWpap.qml:58:13: QML Image: Cannot open: file:///<link of the image>/image.png
    
    

    Images are loaded successfully on desktop but not on android, what could be the solution?



  • Are you sure they are exists and allowed to be accessed?



  • @intruderexcluder yes
    It works when I build for desktop, I figured maybe because my android device can't find the images following their paths since they are on my PC, I think I should load them first and use the new path but I don't know how....



  • I mean can you check this on Android device? There can no be such image, or path isnt valid. Also you should set proper rules to access files on your device, or put your resources as app assets. Make sure if QFile::exists returns true for your path.


  • Lifetime Qt Champion

    Hi,

    To add to @IntruderExcluder, what path are you using ?
    Are you embedding the file using Qt's resource system ?
    Are you using Android's asset system ?
    Is it an absolute path on you drive ?



  • @sgaist
    My path is this:

    file:///D:/felgoProjects/tap_on_the_squares_to_win/assets/replay_image.png
    

    I don't get the second and 3rd question
    Images are saved on my PC and I use their absolute paths


  • Lifetime Qt Champion

    So you are in fact trying to load a file that is located on your computer hard drive from your application running on your Android device. That won't work.

    Either use Qt's resources system and embed the image in your application or use Android's assets system.


Log in to reply