crash - material design android 5.0

前端 未结 5 1732
难免孤独
难免孤独 2020-12-29 23:40

I have a big problem with my app. It crashes and I don\'t know why.

In my app I have a Activity with a listview and a customlistviewa

相关标签:
5条回答
  • 2020-12-29 23:52

    I had this issue in Genymotion, AndroidStudio emulator, couple of real devices.

    My logs were a bit different

    (fbo=13 1440x196)

    but it is not the point.

    This issue happens during shared element transition, and the main reason is because it is pre-rendering target activity (one where your shared transition ends).

    So if this activity is really big (with couple of screens of scrollable text or long grid with images as in my case) you will get this error.

    Solution:

    Paginate your content and load no more than 1-1.5 screens of content at a time.

    This will significantly decrease the screen size that is being pre-rendered during shared elements transition (it's being pre-rendered every time so the system knows where to place your transition object after transition)

    0 讨论(0)
  • 2020-12-29 23:55

    I had the same issue, I found a way to avoid the crash. You can just change the return-transition to others instead of fade, such as: explode/move/slide/...

    To do that you can just add

    <item name="android:windowReturnTransition">@android:transition/explode</item>
    

    to your apptheme file.

    0 讨论(0)
  • 2020-12-30 00:01

    If you take a look at your logs, immediately above the stack trace you'll probably see a warning similar to:

    W/OpenGLRenderer﹕ Layer exceeds max. dimensions supported by the GPU (1080x5856, max=4096x4096)
    

    Scene animations work by creating a bitmap layer of the target scene. The GPU has a maximum capacity for this layer. On a Nexus 5 this is 4096x4096. Your target scene has views in it which result in a layer which is too large, probably due to the large amounts of text content. This exceeds the capacity of the GPU causing the app to crash. The reason why this doesn't occur on the emulator is because the host GPU has a greater memory.

    Solution

    Avoid creating a target layer which is higher than 4096 before the transition animation ends. Instead load your content after the transition ends. You can listen for the transition ended event by implementing the TransitionListener interface. An example of this can be found here. You can then load your content.

    0 讨论(0)
  • 2020-12-30 00:08

    The best solution as it was pointed out in other answers is to add: android:transitionGroup="true" to the long view (usually ScrollView of some kind).

    As for the transition listener approach, don't forget to re-create your view on rotation when there were no shared animations.

    0 讨论(0)
  • 2020-12-30 00:09

    As I still need to support everything down to Android version 9, neither android:transitionGroup="true" nor using TransitionListener would work for me. I could prevent the problem by disabling hardware acceleration on Activity level:

    <activity android:hardwareAccelerated="false" />
    

    Disabling it on a view level didn't work for me, but might work for others:

    myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    
    0 讨论(0)
提交回复
热议问题