// at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1724)
网上说明:
The edge slop code could violate invariants of ScaleGestureDetector, such as the assumption that if an ACTION_POINTER_DOWN is observed or if getPointerCount() >= 2, then there must be at least two active pointers to choose from. But due to the edge slop handling, it was possible for findNewActiveIndex to return -1 in this case, resulting in a crash.
解决方案:
在做多点触控放大缩小,操作自己所绘制的图形时发生这个异常,如果是操作图片的放大缩小多点触控不会出现这个错误
这个bug是Android系统原因 所以第一种方式是:
修改frameworks\base\core\jni\android_view_MotionEvent.cpp的android_view_MotionEvent_nativeGetAxisValue方法
注释掉
- if (!validatePointerIndex(env, pointerIndex, pointerCount)) {return 0;}
改完后需重新编译整个系统,然后替换lib库,重新编译整个系统一般需要半个多小时,这个方法就比较麻烦了第二种方法是:捕获IllegalArgumentException(非法参数异常)异常 即如
- private float spacing(MotionEvent event) {
- try {
- x = event.getX(0) - event.getX(1);
- y = event.getY(0) - event.getY(1);
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
第二种方法简单有效
转自:http://blog.csdn.net/eoeandroida/article/details/7954398