question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash: width and height must be > 0 (v0.2.1)

See original GitHub issue

Every so often I’ll get this crash from prod in one of my apps:

java.lang.IllegalArgumentException: width and height must be > 0
    at android.graphics.Bitmap.createBitmap(Bitmap.java:939)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:918)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:885)
    at com.simplify.ink.InkView.clear(InkView.java:377)
    at com.simplify.ink.InkView.onSizeChanged(InkView.java:160)
    at android.view.View.sizeChange(View.java:16876)
    at android.view.View.setFrame(View.java:16849)
    at android.view.View.layout(View.java:16764)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
     ...

The stack trace is pretty straight forward to follow. The exception appears to be occurring during a layout pass. I’m not doing anything crazy - the InkView is defined in an XML layout. It actually has a specified height (199dp) so it’s the width that must be 0 (match parent).

I’m not sure what the circumstances of this are; maybe the activity is being minimised as a layout pass is occuring?

A fix may be to simply wrap bitmap creation with a size check.

edit: While you’re there… mDebugBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); This line almost doubles the memory footprint of the view; it should probably only be instantiated when debug is enabled.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ZaidMirzacommented, Jun 10, 2018

android:windowSoftInputMode=“adjustPan” putting this in activity solves the problem

0reactions
ZaidMirzacommented, Jun 10, 2018

Im facing same problem. Size changes when keyboard opens via clicking edit text

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crash: width and height must be > 0 (v0.2.1) #11 - GitHub
Every so often I'll get this crash from prod in one of my apps: java.lang.IllegalArgumentException: width and height must be > 0 at...
Read more >
IllegalArgumentException: width and height must be > 0 while ...
I'm using the post method of the View, which will be executed only after the view measuring and layouting, this way getWidth() and...
Read more >
Crash in java.lang.IllegalArgumentException: width and height ...
Crash in java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java).
Read more >
A Crash Course in Python for Scientists - | notebook.community
Thus, the sequence goes 0,1,1,2,3,5,8,13,21,34,55,89,... A very common exercise in programming books is to compute the Fibonacci sequence up to some number n....
Read more >
Kinematics in 1-D
Its speed is v0−gt, so the collision must occur at t = v0/g. Equating this with the above t = h/v0 result tells...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found