Why are no images, in any format, being displayed in my Android Studio app?

JackGreenEarth@lemm.ee to Android@lemmy.world – 8 points –

cross-posted from: https://lemm.ee/post/46066494

I followed the recommended processes for adding images to my app, and it is being displayed correctly on the layout preview, but not at all on the app. I have vector assets, webp, png images, but none are being displayed.

The project is too big to put here in its entirety, but please ask for any snippets that could help you solve the issue. I've tried searching the web and asking LLMs and neither could help, so please help me, fellow humans.

21

Is it not showing up in the emulator, or the phone on which the app is downloaded, or both?

The laptop is not powerful enough to run an emulator, but it shows up on the layout preview but not any of the 3 physical devices I've tested it on

Do any errors show in logcat? You should be able to filter to show errors only.

I can't figure out how to do that, this is all I can see

Type package:mine level:error in the text bar and see if any errors are returned.

And what is the path of your image, and how are you placing the image in your xml file? Here is an example of one that works for me with an image that is located in the res/drawable/baseline_arrow_back_24.xml package

I was using app:srcCompat rather than android:src, maybe that's the difference?

I would try app:src or adding

 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  

To your build.gradle

Have you tested if this issue appears on more than one device configuration? E.g. Your personal physical device and on the emulator?

I tested on three different Android devices but my laptop is not powerful enough to run an emulator so I haven't tried that.

Maybe with some images people can help🤷‍♂️

Ooh it's easy. The layout in android studio is light, on the device is dark. Switch to light and they'll pop up

On the XML icon you have co change the color or apply a different color based light/dark

If not, you can share more like icon XML and stuff

I will try that tomorrow when I have next have access to the device.

Unfortunately switching the theme to light didn't work, the images aren't being displayed at all.

::: spoiler Tap for layout xml




    

    

        

        
    

    

        

            
        
    

    

        

            

            

                

                    

                    

                

                

                    

                    

                    
                

            

        

        
    


:::

::: spoiler Tap for colors.xml



    #FF000000
    #FFFFFFFF

:::

::: spoiler Tap for themes.xml


    
    

    

:::

Have you tried with scr instead of srcCompat?

Yes, but then it gave some error when compiling and failed to compile

Then post the error instead of saying you got an error

I can't remember it right now nor do I have access to the laptop at the moment, but when I do, I will post the exact error I got.

1 more...
1 more...