makeIcon() crashes on android 4.x devices
Closed this issue · 3 comments
StyleableToast Version 2.2.0
Android 4.x
I am trying to create a stylableToast with an icon, which is loaded from the drawable folder. It works fine on newer android versions, but it crashes for android 4.x devices with the following exception.
Fatal Exception: android.content.res.Resources$NotFoundException: File res/drawable/ic_timepicker_light.xml from drawable resource ID #0x7f08006b
at android.content.res.Resources.loadDrawable + 3443(Resources.java:3443)
at android.content.res.Resources.getDrawable + 1921(Resources.java:1921)
at android.support.v4.content.ContextCompat.getDrawable + 465(ContextCompat.java:465)
at com.muddzdev.styleabletoast.StyleableToast.makeIcon + 183(StyleableToast.java:183)
at com.muddzdev.styleabletoast.StyleableToast.inflateToastLayout + 107(StyleableToast.java:107)
at com.muddzdev.styleabletoast.StyleableToast.createAndShowToast + 116(StyleableToast.java:116)
at com.muddzdev.styleabletoast.StyleableToast.show + 125(StyleableToast.java:125)
Have you tried one of these suggested solutions?
I do have this set in my gradle file:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
My toast style looks like this (Icon which crashes the app is commented):
<style name="customToast">
<item name="stTextBold">true</item>
<item name="stTextColor">?attr/toastTextColor</item>
<item name="stTextSize">14sp</item>
<item name="stColorBackground">?attr/fabColor</item>
<item name="stSolidBackground">true</item>
<!--<item name="stIconStart">?attr/toastPickerDrawable</item>-->
<item name="stLength">LONG</item>
<item name="stGravity">center</item>
<item name="stRadius">5dp</item>
</style>
And I call it like this:
StyleableToast.makeText(this, toastMessage, Toast.LENGTH_LONG, R.style.customToast).show();
As I said, it works fine on all android versions except android 4.x API 19
The icon resource is definitely there and accessible, since I use it in other places, where it doesn't crash.
Thanks for your help
Try to set the path to the icon as the following example:
<item name="stIconStart">@drawable/ic_autorenew_black_24dp</item>
Or what is the full path of the icon? where is it located?