"resultIndex is -1, the polygon must be invalid!" adter addView ()

I get an exception after calling the addView () method in 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; } 

An 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 fine on Android Lollipop (SDK <= 22), but it closes with an error in Android Marshmallow (SDK 23). How can I solve this problem?

+5
source share
5 answers

I got the same error and in the same case, the code works fine in api <23, only crash on api 23 that I found in my code, I set the custom animation to the fragment before replacing. (), But after replacing FIRST and THEN setting up 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(); 
+4
source

I get an identical error, only with API 23 and only on real devices, see my problem https://github.com/davideas/FlipView/issues/9

In my case, it seems to set the height in the layout, it breaks the flip animation.

Workaround: I removed the elevation where it was not necessary.

+1
source

This error occurs when you try to start animating a view that is not yet attached to the layout.

However, there seems to be a missing corner, in which in some cases in API 23 (Marshmellow), when you try to animate certain views with a set elevation level, the application closes no matter what.

Let's say your current code is:

 <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 this case, you have several workarounds:

  1. Remove height from view
  2. Delete animation that contains height
  3. Remove height for API 23 only
  4. Remove animation for API 23 only
  5. Temporarily remove the mark and add the mark back after the animation is completed:
 <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(); 
+1
source

In my case, I set cameraDistance for the future property animator for the not added ViewGroup child, like this:

 firstView.cameraDistance = firstView.width * 10f 

Of course, the width was missing, as the view had not yet been added and mocked up (silly mistake), which led to the camera having 0.

As a result, the same error message appears:

"resultIndex is -1, the polygon must be invalid!"

0
source

The stream may be a little old, but I encountered the same problem when trying to animate CardView on a Honor device. Changing CardView to LinearLayout problem (therefore, perhaps this is due to the elevation of CardView over CardView .

Hope this can help someone!

0
source

Source: https://habr.com/ru/post/1233924/


All Articles