Fixed
Status Update
Comments
b9...@gmail.com <b9...@gmail.com> #2
Any update? I think databinding should use AppCompatResources.getDrawable() when widget is AppCompatXXX.
protected static Drawable getDrawableFromResource(View view, int resourceId) {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
return view.getContext().getDrawable(resourceId);
} else {
return view.getResources().getDrawable(resourceId);
}
}
protected static Drawable getDrawableFromResource(View view, int resourceId) {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
return view.getContext().getDrawable(resourceId);
} else {
return view.getResources().getDrawable(resourceId);
}
}
da...@google.com <da...@google.com> #3
Yigit, I'll try to swing by this afternoon to get more information.
b9...@gmail.com <b9...@gmail.com> #4
Sorry, any update?
da...@google.com <da...@google.com> #5
Thanks for pinging - I probably failed to successfully follow up due to pre-I/O churn. I'll assign to me temporarily to make sure I don't forget again, although all I can promise at this point is digging into the issue to better understand it and then prioritize it against other issues.
b9...@gmail.com <b9...@gmail.com> #6
Thanks for following up.
da...@google.com <da...@google.com> #7
It's with great pleasure / relief I can announce this should be fixed with the latest AGP bundled with AS 4.0 Canary 5.
I am sorry it took so long, and I'm sure felt like we had dropped this on the floor. But needless to say it has been on my radar all this time, but I was only able to prioritize / chase it down recently.
Thank you for the excellent github project sample / README. It was very helpful for allowing me to understand the problem quickly.
I am sorry it took so long, and I'm sure felt like we had dropped this on the floor. But needless to say it has been on my radar all this time, but I was only able to prioritize / chase it down recently.
Thank you for the excellent github project sample / README. It was very helpful for allowing me to understand the problem quickly.
Description
The Data Binding Library supports resources in binding expressions, and drawable resources in particular.
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@{condition ? @drawable/image1 : @drawable/image2}" />
But if your project uses support vector drawables you're in a big trouble.
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
Unfortunately, the Data Binding Library doesn't call AppCompatResources.getDrawable() when loading drawables, so the binding above will throw an exception at runtime on pre-Lollipop devices.
See details: