我有一些使用新Palette
类的代码,我在 Crashlytics 上收到这些崩溃报告,说width and height must be > 0
. 奇怪的是,这就是我调用调色板代码的方式:
if( bitmap == null || bitmap.getHeight() <= 0 || bitmap.getWidth() <= 0){
//do something
}else{
Palette.Builder(bitmap).generate(new Palette.PaletteAsyncListener() {
.....
}
所以我只是不确定位图怎么可能突然没有正确的高度或宽度。我不知道异常来自我的哪一段代码,因为报告只包含调色板类中的内容。
这是一个例外:
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)
我正在使用 Palette 类com.android.support:palette-v7:23+
有什么想法可能是错的吗?