Drawables not changing after being replaced with others in the folders

后端 未结 5 932
一个人的身影
一个人的身影 2020-12-16 22:45

I\'ve created a new theme set for an app of mine, and decided I didn\'t need the old one anymore. So, I copied my new image files over the old ones, replacing all of them. I

相关标签:
5条回答
  • 2020-12-16 23:25

    Wipe your bin-folder to remove old compiled data.

    0 讨论(0)
  • 2020-12-16 23:26

    If checking other Drawable folders for old versions and wiping your bin and gen folders didn't work.

    Look for: setImageResource(R.drawable.YourPNG) in your code that might override the drawable configured in xml from: res/layout/ folder.

    0 讨论(0)
  • 2020-12-16 23:37

    The easier solution is to uninstall the app from your emulator then reinstall by running it again from Android Studio. (This will force everything to update)

    This is always a weird problem but I figured this out by deleting the older images from my pc, yet the older image would still show up on the app (which is impossible). So I figured the problem was with the emulator. (since the emulator has its own storage)

    If filepath and file names stay the same I guess Android doesn't update your app, even though the new image is a different size. Weird.

    0 讨论(0)
  • 2020-12-16 23:39

    Android Studio: If Clean and Build doesn´t work try with

    Go to File > Invalidate Caches / Restart

    or File > Synchronize

    both worked for me.

    0 讨论(0)
  • 2020-12-16 23:41

    TL;DR: check your other drawable-xxxdpi folders for old versions too!

    I had this same problem, and none of the solutions here helped. It was driving me crazy.

    I had replaced res/drawable-hdpi/file.jpg with file.png. It was a different extension and had different content. Eclipse was seeing the new version, but no amount of cleaning/refreshing, uninstalling the app or manually deleting bin/gen folders made the device see the new version.

    Then I realized that I had other versions in:

    • res/drawable-ldpi/file.jpg
    • res/drawable-mdpi/file.jpg
    • res/drawable-xhdpi/file.jpg

    Once I replaced those versions with resized versions of file.png, then a simple re-run of the app fixed the issue. It seems like the Android resource compiler saw a "jpg" version of the file first in another of the drawable folders, then ignored the subsequent "png" version in drawable-hdpi. Even though the device it was running on was hdpi, the drawable was coming out of another dpi folder.

    0 讨论(0)
提交回复
热议问题