New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid resource ID crashes the app #413
Comments
The above happens for fixed size or <ImageView
android:id="@+id/image"
android:layout_width="50dp"
android:layout_height="50dp"
/> When the image view has
|
Why should attempting to load an invalid resource id not crash? Unlike most other things, we expect resource ids to be constants. You typically know at compile time which ids will work and which wont? I'm curious what your use case is? |
In a simple answer: because it's not consistent with the rest of the library. I can't think of any other This is actually not a theoretical issue. I ran into it yesterday. I have the images for categories as
which is then handed to
Now, the everyday usage is covered because if the
The current hack is that I check for 0 and replace it with |
[FIX] bumptech/glide#413 is fixed in SNAPSHOT [EXP] Try = instead of MATCH maybe refresh will become faster [COM] Accidental commit of some image related provider experimentation
Glide Version/Integration library (if any): 3.6.0-SNAPSHOT
Device/Android Version: S4/4.4
Issue details/Repro steps: When Glide receives an invalid resource ID it leads to a crashing application. The expected behaviour would be to display the
.error()
image (if any) and callonException
with theResources$NotFoundException
instance and the invalid resource ID asmodel
.Please note that all the other cases I could think of are gracefully (and most of the time correctly) handled. See other cases. below the stack trace.
Glide load line:
Stack trace:
Other Cases
Some parts of the log were cut for brevity.
R.drawable.image
Source: a valid png/jpg file.
Result: all is fine.
R.drawable.drawable
Source: A valid xml drawable, e.g. a
<shape>
.Result:
BitmapFactory
returnsnull
, see #350.R.string.app_name
Source: any resource defined in
values/*.xml
so it doesn't have a full file associated to it.Result: exception is expected and nicely forwarded.
R.layout.main
Source: any resource that has a file associated with it but is not a valid image file (e.g. layout, anim).
Result:
BitmapFactory
returnsnull
, this time correctly.null
Source: nothing.
Result: no exception, but forwarded to
onException
, acceptable, but see #268.The text was updated successfully, but these errors were encountered: