Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalStateException: Unable to create layer for v

I have this exception on crashlytics and have no idea how to reproduce or what the cause might be. Does anyone have any pointers as to where I should start looking? Only affects Android 5+.

Fatal Exception: java.lang.IllegalStateException: Unable to create layer for v
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:323)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5585)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

Thanks.

Edit: I would like to update that it doesn't only affect Android 5, it seems to affect Android 5+

like image 688
casolorz Avatar asked May 02 '17 22:05

casolorz


4 Answers

This issue seems related to Scene transition with hero elements throws Layer exceeds max. dimensions supported by the GPU.

You should look at any activity transaction you are making and particularly for the effects of makeSceneTransitionAnimation().

like image 184
Doron Yakovlev Golani Avatar answered Nov 10 '22 13:11

Doron Yakovlev Golani


Fatal Exception: java.lang.IllegalStateException: Unable to create layer for LinearLayout, size 1080x4160 exceeds max size 4096
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:323)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:6186)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

I have same issue for RecyclerView inside NestedScrollView

RecyclerView <- inside NestedScrollView

Solution: As RecyclerView inside scrollview or nestedscrollview try to load all items at once. As RecyclerView loads all items at once, also loads items that are not visible right now on screen. If you put log inside onBindViewHolder of RecylerView you find that all items loads at the start instead of based on the visibility of the item.

This causes UI to load more than 1-1.5 screens of content at a time. This causes the parent LinearLayout (inside the ScrollView) to throw exception. It's suggested to paginate your content and load no more than 1-1.5 screens of content at a time. I had also issue related to same with Recyclerview without animation.

like image 7
Pradip Tilala Avatar answered Nov 10 '22 13:11

Pradip Tilala


adding android:hardwareAccelerated="false" to application tag in manifest solve my problem

EDIT: please see comment by @inteist

like image 3
Hadi Ahmadi Avatar answered Nov 10 '22 12:11

Hadi Ahmadi


I also faced this issue when I tried to create a simple View. I just had to set android:forceHasOverlappingRendering="false" in its xml. Note that it only works from API level 24.

like image 2
gabhor Avatar answered Nov 10 '22 13:11

gabhor