Exception: width and height must be > 0 when using Ion to load online image
See original GitHub issuehere is how I am loading in a ViewHolder bind method:
if (holder.mItem.imageUrl != null && !holder.mItem.imageUrl.isEmpty())
Ion.with(holder.mImgView)
.animateLoad(null)
.animateIn(null)
.load(holder.mItem.imageUrl);
If I add error or placeholder for Ion that placeholder keep showing. When next time the app runs, the image loads fine. I think at that time the image is downloaded locally (cache), then it works fine. When loading online it doesn’t.
W/System.err: java.lang.IllegalArgumentException: width and height must be > 0
W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:933)
W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:912)
W/System.err: at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
W/System.err: at de.hdodenhof.circleimageview.CircleImageView.getBitmapFromDrawable(CircleImageView.java:337)
W/System.err: at de.hdodenhof.circleimageview.CircleImageView.initializeBitmap(CircleImageView.java:354)
W/System.err: at de.hdodenhof.circleimageview.CircleImageView.setImageDrawable(CircleImageView.java:285)
W/System.err: at com.koushikdutta.ion.IonImageViewRequestBuilder.setIonDrawable(IonImageViewRequestBuilder.java:106)
W/System.err: at com.koushikdutta.ion.IonImageViewRequestBuilder.intoImageView(IonImageViewRequestBuilder.java:180)
W/System.err: at com.koushikdutta.ion.IonImageViewRequestBuilder.load(IonImageViewRequestBuilder.java:72)
W/System.err: at com.xoredgeapps.bayanstube.fragments.DashboardRealmRecyclerViewAdapter.onBindRealmViewHolder(DashboardRealmRecyclerViewAdapter.java:61)
W/System.err: at com.xoredgeapps.bayanstube.fragments.DashboardRealmRecyclerViewAdapter.onBindRealmViewHolder(DashboardRealmRecyclerViewAdapter.java:21)
W/System.err: at io.realm.RealmBasedRecyclerViewAdapter.onBindViewHolder(RealmBasedRecyclerViewAdapter.java:285)
W/System.err: at io.realm.RealmBasedRecyclerViewAdapter.onBindViewHolder(RealmBasedRecyclerViewAdapter.java:49)
W/System.err: at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5825)
W/System.err: at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5858)
W/System.err: at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5094)
W/System.err: at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970)
W/System.err: at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
W/System.err: at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:541)
W/System.err: at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
W/System.err: at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
W/System.err: at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
W/System.err: at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315)
W/System.err: at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3124)
W/System.err: at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3568)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:613)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
W/System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
W/System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
W/System.err: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
W/System.err: at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1767)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
W/System.err: at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
W/System.err: at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1364)
W/System.err: at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:846)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
W/System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
W/System.err: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
W/System.err: at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
W/System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
W/System.err: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
W/System.err: at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
W/System.err: at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
W/System.err: at android.view.View.layout(View.java:16711)
W/System.err: at android.view.ViewGroup.layout(ViewGroup.java:5328)
W/System.err: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2319)
W/System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2032)
W/System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191)
W/System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642)
W/System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
W/System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:590)
W/System.err: at android.view.Choreographer.doFrame(Choreographer.java:560)
W/System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:145)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5951)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
IllegalArgumentException: width and height must be > 0 - error ...
IllegalArgumentException : width and height must be > 0 - error when loading an image using Imgcodecs.imread ... I'm using Imgcodecs.imread to ...
Read more >getimagesize - Manual - PHP
The getimagesize() function will determine the size of any supported given image file and return the dimensions along with the file type and...
Read more >Image (MID Profile) - Oracle Help Center
Immutable images are generally created by loading image data from resource bundles, ... The width and height of the image must both be...
Read more >Setting Height And Width On Images Is Important Again
Yes, when an image is being shown at full size, without any CSS changing any dimensions, it is useful to resolve the layout...
Read more >Objects, Images, and Applets in HTML documents
Width and height ; White space around images and objects; Borders; Alignment ... To include applets, authors should use the OBJECT element as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I haven’t worked with Ion myself but I guess it uses some kind of custom drawable that is causing the issue. You should be able to work around this by loading the Bitmap into a callback and provide it to the CircleImageView yourself, like this (untested):
@hdodenhof in my case the issue was the drawable needs to have height and width, but this atribute for shapes is available on version 23, so it might still crash on old devices