I have some code using the new Palette
class and I'm getting these crash reports on Crashlytics saying that the width and height must be > 0
. What is odd is that this is how I call the palette code:
if( bitmap == null || bitmap.getHeight() <= 0 || bitmap.getWidth() <= 0){
//do something
}else{
Palette.Builder(bitmap).generate(new Palette.PaletteAsyncListener() {
.....
}
So I am just not sure how it is possible that the bitmap all of the sudden doesn't have the right height or width. I don't know which piece of my code the exception is coming from because the report only include stuff inside the palette class.
Here is the exception:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:815)
at android.graphics.Bitmap.createBitmap(Bitmap.java:794)
at android.graphics.Bitmap.createBitmap(Bitmap.java:725)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:601)
at android.support.v7.graphics.Palette.scaleBitmapDown(Palette.java:282)
at android.support.v7.graphics.Palette.access$100(Palette.java:67)
at android.support.v7.graphics.Palette$Builder.generate(Palette.java:557)
at android.support.v7.graphics.Palette$Builder$1.doInBackground(Palette.java:623)
at android.support.v7.graphics.Palette$Builder$1.doInBackground(Palette.java:620)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
I am using the Palette class from com.android.support:palette-v7:23+
Any ideas of what might be wrong?