I get an exception after calling addView() method on ViewGroup (FrameLayout).
public final View createView(Context context, Property property, ViewGroup parent) {
        mView = LayoutInflater.from(context).inflate(getLayout(), null);
        mContext = context;
        mProperty = property;
        processBaseViews(mView, property);
        processViews(mView, property);
        parent.addView(mView);
        return mView;
    }
Exception:
10-17 18:39:40.060: E/OpenGLRenderer(511): resultIndex is -1, the polygon must be invalid!
10-17 18:39:40.061: A/libc(511): Fatal signal 7 (SIGBUS), code 1, fault addr 0x136 in tid 726 (hwuiTask1)
This code works normally on Android Lollipop (SDK <= 22), but closes with error on Android Marshmallow (SDK 23). How can I solve this problem?
I was receiving the same error also same case, the code works fine in api<23 only crashes on api 23 what I found is in my code i was setting custom animation to a fragment BEFORE replace.() but after FIRST replacing and THEN setting custom animation just worked for me. here is my code snippet
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.fragment_container, fragment);
    transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
    transaction.commit();
This bug happens when you try to start animating a view that isn't attached to the layout yet.
However, there seems to be a missed corner where in certain cases in API 23 (Marshmellow), when you try to animate a certain views with elevation set, it will close the app no matter what.
Let's say the following is your current code:
<FrameLayout
   android:id="@+id/container"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:elevation="@dimen/custom_elevation" />
   container.animate()
            .scaleX(1f)
            .scaleY(1f)
            .setListener(null)
            .start();
In that case, you have couple options for the workaround:
<FrameLayout
   android:id="@+id/container"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" />
   container.animate()
            .scaleX(1f)
            .scaleY(1f)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    final float elevation = container.getDimension(R.dimen.custom_elevation);
                    container.setElevation(elevation);
                }
            })
            .start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With