Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
My application work very well on nougat emulator and many devices, but i found this exception in google play crash reporter, I don't know why it happened, The exception causes with nougat devices ++ only.
the exception :
java.lang.RuntimeException:
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
at android.graphics.Canvas.drawBitmap(Canvas.java:1420)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
at android.view.View.getDrawableRenderNode(View.java:18591)
at android.view.View.drawBackground(View.java:18527)
at android.view.View.draw(View.java:18315)
at android.view.View.updateDisplayListIfDirty(View.java:17302)
at android.view.View.draw(View.java:18086)
at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty(View.java:17297)
at android.view.View.draw(View.java:18086)
at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty(View.java:17297)
at android.view.View.draw(View.java:18086)
at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty(View.java:17297)
at android.view.View.draw(View.java:18086)
at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty(View.java:17297)
at android.view.View.draw(View.java:18086)
at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
at android.view.View.draw(View.java:18327)
at com.android.internal.policy.DecorView.draw(DecorView.java:919)
at android.view.View.updateDisplayListIfDirty(View.java:17302)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:698)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:806)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3135)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2931)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2523)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1522)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7098)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
What this error could be?
CAUTION: all drawable i used is less than 1MB.
–
–
I had the exact same problem with Samsung Galaxy S6 S7 S8
. In my case Splash Screen had high resolution and it was mistakenly placed in the drawable folder. I found solution from this answer.
Right Click on drawable
-> New
-> Directory
.
Enter new directory name: xxhdpi
. It will create a new folder named drawable-xxhdpi
if you go to res
Move your splash image from drawable
to drawable-xxhdpi
.
–
–
Just Resize your image in my case my Splash screen image dimensions are 1544x2100 so i changed to 1080x2100 and that will work!!
Hope this will help!!!
Thanks!!!
–
–
@Override
protected void throwIfCannotDraw(Bitmap bitmap) {
super.throwIfCannotDraw(bitmap);
int bitmapSize = bitmap.getByteCount();
if (bitmapSize > MAX_BITMAP_SIZE) {
throw new RuntimeException(
"Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap.");
See this code in DisplayListCanvas,otherwise look at View#draw() method,
boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
boolean drawingWithRenderNode = mAttachInfo != null
&& mAttachInfo.mHardwareAccelerated
&& hardwareAcceleratedCanvas;
if (drawingWithRenderNode) {
// Delay getting the display list until animation-driven alpha values are
// set up and possibly passed on to the view
renderNode = updateDisplayListIfDirty();
if (!renderNode.isValid()) {
// Uncommon, but possible. If a view is removed from the hierarchy during the call
// to getDisplayList(), the display list will be marked invalid and we should not
// try to use it again.
renderNode = null;
drawingWithRenderNode = false;
that why we can resolve the problem by cancel the hardwareAccelerated
–
To anyone who still needs an answer to this question(as I did two days ago) the answer is simple: Resize all your images that are above 1024 x 1024 to 1024 x 1024, for example I had an image with something like 1080 x 850, that 1080 is a problem and would thus need to be resized and scaled down to 1024 and if you use a photo editing tool, when scaling it will automatically set the correct width / length to your image
Just an addition to the Shuvo Joseph's answer, maybe it's a good idea to not only add drawable-xxhdpi
density folder, but also add another density folder.
So whatever the android version and size, your app can prepare the image source with the right size :
Change your folder view on the top left from Android to Project
Go to YourProjectFolder folder > app > src > main > res
Prepare the original image with your best resolution, and split it into each folder size automatically. You can do it in Baker
Then create a folder with another density, namely:
drawable-hdpi
, drawable-ldpi
, drawable-mdpi
, drawable-xhdpi
, drawable-xxhdpi
, drawable-xxxhdpi
Put each image into the appropriate folder
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.