MotionEvent error on !CS (4.0.3)

splatt

Active Member
Licensed User
Longtime User
I've seen a couple of examples of this error reported on the forum, but can't see a solution.

Problem only occurs on ICS on a game I've had on the market for over a year.

Problem occurs when user changes settings. An InputList is displayed and when an item on the list is selected the program stops with the following error. NOTE: I do not have any calls to DoEvent in the code. Using B4A Version 2



Unfiltered LogFile:

B4X:
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40c511f8)
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=117.0, y[0]=443.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4505983, downTime=4505675, deviceId=2, source=0x1002 } recycled twice!
   at android.view.MotionEvent.recycle(MotionEvent.java:1670)
   at android.view.ViewRootImpl.finishMotionEvent(ViewRootImpl.java:3130)
   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3121)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2657)
   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:1021)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2666)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4507)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
   at dalvik.system.NativeStart.main(Native Method)
FATAL EXCEPTION: main
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=117.0, y[0]=443.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=4505983, downTime=4505675, deviceId=2, source=0x1002 } recycled twice!
   at android.view.MotionEvent.recycle(MotionEvent.java:1670)
   at android.view.ViewRootImpl.finishMotionEvent(ViewRootImpl.java:3130)
   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3121)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2657)
   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:1021)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2666)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4507)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
   at dalvik.system.NativeStart.main(Native Method)
  Force finishing activity r.intent.getComponent().flattenToShortString()
GC_CONCURRENT freed 248K, 3% free 14477K/14919K, paused 5ms+4ms
!@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
 

splatt

Active Member
Licensed User
Longtime User
You should update to B4A 2.02 and try it. I had a few issues something like this and then updated to 2.02 and they were gone.

Do you know if I can get this with the same Username\Password as Version 2?
 
Upvote 0

splatt

Active Member
Licensed User
Longtime User
Thanks for that Margret, but the problem is still there, even with 2.02.
 
Upvote 0

splatt

Active Member
Licensed User
Longtime User
When you opened the project in 2.02 did you use Tools/Clean Project before you recompiled your APP? Some files are not always rewritten. I manually go to my project folder and delete them so I get a complete new compile.

Done that but the problem persists.
 
Upvote 0

splatt

Active Member
Licensed User
Longtime User
Can you post a simple program that produces this error?

I've tried creating a dummy project, but it doesn't happen on that!

I've copied code from the program that is having the problem.

The user presses the Menu Key and a listview is displayed.

B4X:
Sub lvSettings_ItemClick (Position As Int, Value As Object)
   Try
      Select Value
         Case "GM" :
            AdvancedMode = Not(AdvancedMode)

         Case "TM" :
            GameTimer.Initialize("GameTimer", 1000) '1 second
            TimedMode = TimedMode + 1
            If TimedMode = 3 Then TimedMode = 0

            GameTimer.Enabled = (TimedMode>0)
            prgTimer.Visible=(TimedMode > 0)
            'Initialise(True)
            'GameTimer_Reset(TimedMode)
      Case "CP" : 
         GetPegSet  'btnFiles_Click
      Case "CB" :
         GetBG  'Change_Background
      Case "SFX" : 
         SoundFx = Not(SoundFx)
      Case "CS" :
         If LeftOrRight = "Right" Then LeftOrRight = "Left" Else LeftOrRight = "Right"
         'Activity_Resume
      End Select
      CreateSettings
      CreateTitles
   Catch
      Log("lvSettings_ItemClick - "&LastException.Message)
   End Try
   'SaveValues
End Sub

Sub GetPegSet
   Dim opts As List
   Dim ret, cur As Int
   Dim su As StringUtils
   Dim Table As List
   
   Select Case PegSet
      Case "default.lst" : cur = 0   '[16]
      Case "metal.lst"   : cur = 1   '[16]
      Case "numbers.lst" : cur = 2   '[16]
      Case "plastic.lst" : cur = 3   '[16]
      Case Else :  cur = 4         '[16]
   End Select
   
   opts.Initialize
   opts.Add("Default") '[16]
   opts.Add("Metal")
   opts.Add("Numbers")
   opts.Add("Plastic")
   
   If UsingSDCard Then opts.Add("External Set")
   
   ret = InputList(opts, "Select Peg Set Required",cur)
   PegsDirectory = File.DirAssets
   Select ret
      Case 0: PegSet = "default.lst"   '[16]
      Case 1: PegSet = "metal.lst"      
      Case 2: PegSet = "numbers.lst"
      Case 3: PegSet = "plastic.lst"
      Case 4: GetExternalPegs   'Get external Directory
   End Select
      Try

      Table = su.LoadCSV(PegsDirectory, PegSet, ",")
      For i = 0 To Table.Size - 1
          Dim cells() As String
          cells = Table.get(i)
          For c = 0 To cells.Length - 1
            Pegs(c) = Utils.StripChars(cells(c),Chr(34))
              'Log(Pegs(c)&" - "&pegs(c).Length)
          Next
      Next
      pnlSettings.RemoveView
   Catch
      Log("GetPegSet - "&LastException.Message)
   End Try
End Sub

The problem only occurs when 'GetPegSet' or 'GetBG' are called. In both cases, the execution returns to ' lvSettings_ItemClick' and continues to the end of that subroutine. The program then hangs for about 20 seconds before the "Unfortunately .... has stopped" error is displayed.
 
Upvote 0

splatt

Active Member
Licensed User
Longtime User
You can try using CallSubDeyed to call GetPegSet and GetBG.

I have just tried that but the problem persists.

I assumed that CallSubDelayed(Null, GetPegSet) is correct if calling in the current activity?
 
Upvote 0
Top