31

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+

5
  • Are you developing a native app or other platforms like Xamarin? May 8, 2017 at 17:19
  • Normal Android with Java.
    – casolorz
    May 8, 2017 at 18:14
  • I assume you have some kind of comprehension as to where this happens. Copy-paste the code and layout for the relevant activity into your question
    – Zoe
    May 14, 2017 at 14:35
  • I don't really know where it happens because the crash report from Crashlytics doesn't give me any more information and it has never happened to me and no user has ever reported it. That being said, this answer stackoverflow.com/a/43853650/704836 might be onto something as I do use makeSceneTransitionAnimation once in my code for a very simple ImageView. Since I don't know of any users experiencing the issue, it is a bit hard to test it.
    – casolorz
    May 15, 2017 at 1:21
  • This happens mostly with FireOS devices. No idea why. Feb 26, 2018 at 15:35

5 Answers 5

11
+50

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().

3
  • I do have one call to makeSceneTransitionAnimation in which I pass a simple ImageView. Thanks for link.
    – casolorz
    May 8, 2017 at 18:14
  • @casolorz Did it stop the crashes? Can you share your experience? Jun 24, 2021 at 14:07
  • This specific crash has gone away over time (this question is from 2017) but I don't remember if it was because of that makeSceneTransitionAnimation or if it just went away on its own with time.
    – casolorz
    Jun 24, 2021 at 19:11
7
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.

0
3

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

EDIT: please see comment by @inteist

1
  • 12
    this is not a good solution. It makes everything super jagged and slow. No reason to punish everyone because Samsun and LG screwed up a few of their models.
    – inteist
    Feb 22, 2020 at 18:31
2

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.

2
  • But where do I put that? I don't even know what activity it is happening under.
    – casolorz
    Oct 15, 2018 at 21:56
  • Yes, it's hard to find because log doesn't contain any information about that view element. I suggest you go through your app screen by screen and try to figure out which activity/fragment contains that view because the app is going to crash when it tries to render it. Another way is using git bisect if you source controlled your project with git. First you have to find a previous commit when it worked, then you can find the commit - which contains the buggy part - with bisect. Here you can find more information about how to use bisect: git-scm.com/docs/git-bisect
    – gabhor
    Oct 16, 2018 at 11:30
0

In my case, it was a silly mistake and Android Studio didn't show any warning.

I had a view set with the id of @+id/myView yet I had also set in the same view/tag android:layout_below=@id/myView.

Something like this:

<TextView
    android:id="@+id/textview"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_below="@id/textview" /> <!-- The traitor :( -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.