Why are no images, in any format, being displayed in my Android Studio app?
from JackGreenEarth@lemm.ee to programming@programming.dev on 30 Oct 2024 09:57
https://lemm.ee/post/46136220

cross-posted from: 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.

#programming

threaded - newest

Deckweiss@lemmy.world on 30 Oct 2024 10:23 collapse

Anything in the log?

Are you testing in the android studio emulator or on a real phone?

Please share the “recommended processes” that you’ve followed.

And your project settings.

JackGreenEarth@lemm.ee on 30 Oct 2024 10:32 next collapse

Anything in the log?

Plenty, but nothing that is obvious enough to me as a newbie to android dev. Maybe it’s obvious to someone more experienced though, the log is too long to post in this comment, but here is a link to the file.

https://share.jackgreenearth.org/logcat/samsung-SM-A405FN-Android-11_2024-10-30_102911.txt

Deckweiss@lemmy.world on 30 Oct 2024 10:38 collapse

I get a “URL not found” error on your link. Maybe just put in on pastebin.

Also, I have a bad habbit of editing my posts a lot, sorry, but please read it again when it propagates and reply to the other points as well.

JackGreenEarth@lemm.ee on 30 Oct 2024 10:41 collapse

I edited the link to txt so it should work now, although for me it was white on white so I had to ctrl-a the text to read it. I replied to your other points in a separate comment

JackGreenEarth@lemm.ee on 30 Oct 2024 10:39 collapse

I’ve tested it on 3 real phones, I imported the vector graphics from the google database of default vector graphics and followed the android studio docs page on how to import images, I used the srcCompat attribute and added vectordrawable to the build.gradle.kts.

How do I share my project settings? Is that a file?

Deckweiss@lemmy.world on 30 Oct 2024 10:48 collapse

Share your gradle.kts and a screenshot from this menu:

File>ProjectStructure ( developer.android.com/studio/projects#ProjectStru… )

JackGreenEarth@lemm.ee on 30 Oct 2024 12:35 collapse

Tap for Kotlin script

plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) } android { namespace = “org.jackgreenearth.materialmusic” compileSdk = 35 defaultConfig { applicationId = “org.jackgreenearth.materialmusic” minSdk = 30 targetSdk = 35 versionCode = 1 versionName = “1.0” testInstrumentationRunner = “androidx.test.runner.AndroidJUnitRunner” } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile(“proguard-android-optimize.txt”), “proguard-rules.pro” ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = “1.8” } buildFeatures { viewBinding = true } } dependencies { implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(libs.material) implementation(libs.androidx.constraintlayout) implementation(libs.androidx.navigation.fragment.ktx) implementation(libs.androidx.navigation.ui.ktx) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) implementation(libs.androidx.vectordrawable) implementation(libs.androidx.vectordrawable.animated) }

<img alt="" src="https://lemm.ee/pictrs/image/477cd1cb-cb9c-4c93-9e88-7136b311652c.png">

Deckweiss@lemmy.world on 31 Oct 2024 01:13 collapse

I’ll look into it on the weekend in detail if nobody else can spot the issue until then.

So far, everything looks normal and I didn’t see anything in the log at a glance. (besides a bunch of res related warnings that I am not sure about)

Are the images in your res folder / do you see them when you go to View > Tool Windows > Resource Manager ?

JackGreenEarth@lemm.ee on 31 Oct 2024 07:43 collapse

I do see them when I go to the resource manager