Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can't view a png image on android
Forum Updated to NodeBB v4.3 + New Features

Can't view a png image on android

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 1.2k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    newbiSoso
    wrote on 11 Aug 2019, 17:07 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      IntruderExcluder
      wrote on 11 Aug 2019, 18:34 last edited by
      #2

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

      N 1 Reply Last reply 11 Aug 2019, 19:30
      0
      • I IntruderExcluder
        11 Aug 2019, 18:34

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

        N Offline
        N Offline
        newbiSoso
        wrote on 11 Aug 2019, 19:30 last edited by
        #3

        @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....

        1 Reply Last reply
        0
        • I Offline
          I Offline
          IntruderExcluder
          wrote on 11 Aug 2019, 19:52 last edited by
          #4

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 11 Aug 2019, 19:59 last edited by
            #5

            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 ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            N 1 Reply Last reply 12 Aug 2019, 09:46
            0
            • S SGaist
              11 Aug 2019, 19:59

              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 ?

              N Offline
              N Offline
              newbiSoso
              wrote on 12 Aug 2019, 09:46 last edited by
              #6

              @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

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 12 Aug 2019, 18:30 last edited by
                #7

                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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2

                6/7

                12 Aug 2019, 09:46

                • Login

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