I'm working on a bug of my Android application and it only occurs on a Galaxy Nexus with Android version 4.2.2, but works fine on my Nexus 5 with 4.4.2.
Basically it's not able to find a png file on this device.
The png file is only located in res/drawable and here is the structure of my res folder:
res/drawable
res/drawable-de
res/drawable-fr
res/drawable-it
res/drawable-hdpi
res/drawable-ldpi
res/drawable-mdpi
res/drawable-xhdpi
res/drawable-xxhdpi
What could be preventing Android to fallback to the drawable folder in this case?
Without knowing anything about the image its hard to say, but the image may be too large. Alternatively, unless there's a compelling reason not to, you should probably put it in a *dpi folder anyway
What is the configuration of your device when the drawable resource couldn't be found? When the device language is German, it might happen that one of the resource directory, e.g res/drawable-de has taken precedence of the drawable directory.
Take a look at here how android find the best matching resources.
Related
So I was pasting some image in the drawable folder and I found that there are 2 folders as you can see in below picture
one is drawable and another is drawable-v24
So my questions are
why there are 2 drawable folders ?
whats the diff. ?
Do we really need them ?
any additional information is deeply appreciated . :)
The drawable folder is the default folder. The drawable-v24 applies to only those devices with Android v24 or higher- any file in that directory will be used instead of the file with the same name in drawable on the applicable versions. Do you need them both? Only if you want different images on newer devices, or if there's some feature of v24 and higher that you want to take advantage of where available. If not you can safely delete it.
There are many drawable folder types based on many factors,
Android OS version, ex: drawable-V21, drawable-V22, drawable-v23...etc
Density pixels - Refer https://developer.android.com/training/multiscreen/screendensities
This different folder types are used to access the images for particular needs, say if you have to load a small size icon in Lollipop OS and a different size icon in all other OS, you have to use drawable-V21 for lollipop and normal drawable folder for all others.
Another case based on the resolution of mobile phones, quality will vary on images, example: drawable-hdpi images supports Full HD mobiles, whereas drawable-xxhdpi support QuadHD mobiles and so on..
Recently, I get quite a number of crash reports
android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-v4/flag_au.png from drawable resource ID #0x7f0200bc
at android.content.res.Resources.loadDrawable(Resources.java:1970)
at android.content.res.Resources.getDrawable(Resources.java:660)
I feel strange that, as the crash reports are from Android 4.2, device #Tab7QC-16
I do have resource in xhdpi. I expect Android 4.2 should pick resources from xhdpi.
I don't plan to provide drawable folder. As, I will place mdpi sized image into it. When the targeted device scales up it to xhdpi, it will not look nice.
I think I can "solve" the crash, by cloning folder xhdpi to xhdpi-v4.
But, the question is, why Android 4 will try to fetch resource from drawable-xhdpi-v4?
As I see it, folder resources work the exact opposite way.
The qualifier drawable-v4, for instance, refers to API level 4 and higher, not lower. So if you have these folders:
drawable
drawable-v4
drawable-v15
The drawable-v15 folder will stand for API 15-23 (up to now), drawable-v4 for API 4-14, and drawable for API levels that do not get a match with previous folders (thus API 1-3).
You should probably reformat your folders in this sense.
This is the reference page in the official documentation. For some reason at this moment I can only load it in chinese (I think) but looking at the google cache it seems to support my opinion.
I'm developing an android game and will try cover as many different phone and tabled screen sizes and resolutions as possible. To make it easier to handle graphics I've designed some of my icons so that for example a 7" mdpi tablet uses same icons as an xhdpi phone.
That means I have put exactly the same icon file in drawable-xhdpi folder as in drawable-sw600dp-mdpi. I also have same files in drawable-land-xhdpi as in drawable-sw600dp-land-mdpi. It doesn't feel good to have duplicate files, can it be avoided somehow? Or how smart is eclipse compiler, can it detect duplicate files and compress the apk file accordingly?
You can avoid duplicating image files by using aliases. An image alias is an XML resource file containing a <bitmap /> tag. Look at the documentation for the syntax.
In your case I think you should name your resources differently for phone and tablets if they don't end up having the same density-independent size. From what I understand, your tablet images are bigger than your phone images, which is generally not a good idea.
For some reason, the drawables in my app are blurry. This is especially apparent in menus when I put built-in system icons side-by-side with icons from my project's res folder.
Here's an example. The left envelope icon is in my app's drawable-hdpi folder. It is scaled down, for some reason. The right one is using the built-in Android resources. As far as I can tell, they are the same 72x72px file--I copied the png straight from the drawable-hdpi folder in SDK to my project's drawable-hdpi folder.
Is there some special setting for drawables in my app that I'm missing?
Try adding the appropriate supports-screens element to your Android manifest, and make sure you have a min-sdk of at least 4. Also make sure your uses-sdk element is nested under the manifest and not under the application (if it's in the wrong place or missing, your app will still work but can cause issues with compatibility-related code like resource scaling, and will prevent uploading to the market with an obscure error... it can be a tough one to track down).
Are you using an mdpi screen? If so then your device is having to take the drawables from drawables-hdpi and scale them down, which would likely cause them to blur.
You might try also copying the -mdpi resources to your drawable-mdpi folder, which would allow the framework use your drawables without adjusting for screen density.
Edit - now that I think about it, I'm not sure why your image would appear smaller unless your screen had a greater dpi than hdpi.
good day
we are developing game for android and have some trouble with resource loading on high dpi devices.
our resources are located in res/drawable directory
on a standart dpi device the game work properly, but on hdpi (tested on HTC Desire) all resources which located in res/drawable-hdpi load are loaded correctly, but the resources which miss in drawable-hdpi directory but present in res/drawable are ignored
but everything works fine on the virtual device with hdpi.
does anybody encounter this problem and know how to solve it?
Well from non device tester advice here, can You move those missing resources to drawable/nodpi if that does not conflicts your development strategy ?
Don't know to what extent it will work, but u can try!