Issue
I'm getting a crash in the Android Studio emulator and in the Google PLay Pre-Launch checks for just oe device.
The resource listed defintely exists in my source - it is in the drawable
folder rather than any specific dpi folder - and it is found on all other devices I've tried my app on, that is emulator devices, Pre-launch Test devices and a couple of physocal devices.
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_amalfi_pro_link.xml from drawable resource ID #0x7f080071
The main differences that I can see with teh device that is failing is that it is lower resolution - hence me checking that the vector drawables are in teh drawable folder, not a specific dpi folder.
The crashing device is also API 19 whereas the working devices are later versions. (I get a similar crash for a different resource that I haven;t fully investogated yet for API 21 in the Pre Launch teses).
Note that I have legacy support for vector drawables enabled in my build.gradle (app)
with:
vectorDrawables {
useSupportLibrary true
}
I have tried a clean build - no change.
I have tried invalidating caches and rebuilding - no change.
I have tried changing the drawable for something else, changing back and rebuilding - no change.
I did have the same crash with a different drawable on teh same emulator test device and replacing that drawable with a differen drawable avoided that first crash and moved me oon to this next drawable causing the crash, so it does seem to e related to specific drawables - BUT the drawable IS there and does work on other devices.
This is so frustrating, I just don't know where else to look for the issue.
Update:
Following the content below requiring clarification regarding whether the vector drawable in question is used in any other activity I tested some more.
- if I add the failing drawable to my main activity it works perfectly in my main activity but still fails to be found in the activity in which it causes the crash and still causes the crash
- I appear to have at least three vector drawables in my project that are behaving the same way, in three different activities
- if I replace the offending drawable in the crashing activity with another vector drawable (not one of the others that is causing a crash) then the activity in question does not crash.
- if I replace the offending drawable in three crashing activity with one of the other offending drawables then the activity crashes reporting that the new offending drawable cannot be found.
I have checked the drawable XML and it is identical (other than the path details) to other vector drawables I am using on this project that do not cause the crash.
Solution
Starting with release 1.1.0-alpha01
of the AndroidX AppCompat library, there are "compat" attributes for compound vector drawables:
app:drawableTopCompat
app:drawableLeftCompat
app:drawableStartCompat
- etc
You must be using AppCompatTextView
to leverage these attributes. If your layout is inflated by a LayoutInflater
built from an AppCompat theme, this will happen automatically when you use <TextView>
tags. If not, you will have to explicitly specify them as <androidx.appcompat.widget.AppCompatTextView>
tags.
Answered By - Ben P.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.