android 4.3下报IllegalStateException: Already in the pool!

移动开发 码拜 6年前 (2015-07-11) 1077次浏览 0个评论

我的程序有个左侧菜单sliding menu,用fragment做的,里面有个SlidingView的类,里面有用到VelocityTracker来检测滑动的速度.在android 4.2之前都没问题的,昨天把手机升到4.3了,发现一但进行手势滑动的时候就报错.具体是用到VelocityTracker类里的recycle()方法.请问有大神知道是什么问题吗 如果不适用这个回收方法或者用try,就不会报错,但是整个滑动的效果就没那么流畅了.

if (mVelocityTracker != null) {
				mVelocityTracker.recycle();
				mVelocityTracker = null;
			}

错误是

08-01 14:55:18.629: W/System.err(17807): java.lang.IllegalStateException: Already in the pool!
08-01 14:55:18.629: W/System.err(17807): 	at android.util.Pools$SimplePool.release(Pools.java:112)
08-01 14:55:18.629: W/System.err(17807): 	at android.util.Pools$SynchronizedPool.release(Pools.java:161)
08-01 14:55:18.629: W/System.err(17807): 	at android.view.VelocityTracker.recycle(VelocityTracker.java:85)
08-01 14:55:18.629: W/System.err(17807): 	at com.test.demo.layout.SlidingView.onTouchEvent(SlidingView.java:266)
08-01 14:55:18.629: W/System.err(17807): 	at android.view.View.dispatchTouchEvent(View.java:7384)
08-01 14:55:18.629: W/System.err(17807): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2203)
08-01 14:55:18.629: W/System.err(17807): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1938)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
08-01 14:55:18.639: W/System.err(17807): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
08-01 14:55:18.639: W/System.err(17807): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
08-01 14:55:18.639: W/System.err(17807): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
08-01 14:55:18.639: W/System.err(17807): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.View.dispatchPointerEvent(View.java:7564)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
08-01 14:55:18.639: W/System.err(17807): 	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
08-01 14:55:18.639: W/System.err(17807): 	at android.os.MessageQueue.nativePollOnce(Native Method)
08-01 14:55:18.639: W/System.err(17807): 	at android.os.MessageQueue.next(MessageQueue.java:132)
08-01 14:55:18.639: W/System.err(17807): 	at android.os.Looper.loop(Looper.java:124)
08-01 14:55:18.639: W/System.err(17807): 	at android.app.ActivityThread.main(ActivityThread.java:5103)
08-01 14:55:18.639: W/System.err(17807): 	at java.lang.reflect.Method.invokeNative(Native Method)
08-01 14:55:18.639: W/System.err(17807): 	at java.lang.reflect.Method.invoke(Method.java:525)
08-01 14:55:18.639: W/System.err(17807): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-01 14:55:18.639: W/System.err(17807): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 14:55:18.639: W/System.err(17807): 	at dalvik.system.NativeStart.main(Native Method)
 
老兄啊,遇到和你一模一样的问题,我也是SlidingMenu的OnTouchEvent方法中抛的
 

我也是那里抛.你也升了4.3了吗 有没有其他大神知道怎么办 我看过android新的api文档,这个方法貌似没变化啊.

100分

引用 3 楼 SunBo_Java 的回复:

老兄啊,遇到和你一模一样的问题,我也是SlidingMenu的OnTouchEvent方法中抛的

加个try…catch怎么样

 
引用 6 楼 liuxian13183 的回复:
Quote: 引用 3 楼 SunBo_Java 的回复:

老兄啊,遇到和你一模一样的问题,我也是SlidingMenu的OnTouchEvent方法中抛的

加个try…catch怎么样

只能加个try/catch了,但是我觉得这个问题会影响到滑动的流畅性.发现有其他的方式来实现sliding menu,建议用其他开源包来实现.

 
不要存在两个这个一样的对象就不会了
 
去掉recycle方法试一下

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明android 4.3下报IllegalStateException: Already in the pool!
喜欢 (1)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!