Why Android 4.2 will try to extract a resource from drawable-xhdpi-v4

I've been getting quite a lot of crash reports lately

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) 

It seems strange to me that since crash reports from Android 4.2 , device @ Tab7QC-16

I have a resource in xhdpi . I expect Android 4.2 to allocate resources from xhdpi .

I do not plan to provide a drawable folder. Like, I put an mdpi image in it. When the target device scales it to xhdpi, it doesn't look very good.

I think I can "solve" the crash by cloning the xhdpi folder to xhdpi-v4.

But the question is, why does Android 4 try to extract the resource from drawable-xhdpi-v4?

+5
source share
1 answer

As I see it, folder resources work in exactly the opposite way.

The drawable-v4 qualifier, for example, refers to API level 4 and above , not lower . So, if you have these folders:

  • range hood
  • draw v4
  • draw-v15

The drawable-v15 folder will display API 15-23 (still), drawable-v4 for API 4-14 and drawable for API levels that do not match the previous folders (thus, API 1-3).

You should probably reformat your folders in that sense.

This is the help page in the official documentation. For some reason, at this moment I can only download it in Chinese (I think), but looking at the Google cache it seems to support my opinion.

+3
source

Source: https://habr.com/ru/post/1233196/