Android Question Troubleshooting problem

Discussion in 'Android Questions' started by GuyBooth, May 6, 2015.

  1. GuyBooth

    GuyBooth Active Member Licensed User

    I'm having difficulty identifying a problem in my code. The error only shows up when I am using legacy debug, and probably 90% of the time. The other 10% the problem doesn't show. There is too much code to post the code itself, and some of it is asynchronous - so the messages I have logged that immediately precede the problem are not a good indicator of exactly where the problem is.

    The log is as follows:
    Code:
    Trying to connect with 192.168.3.46:8080
    Connection Successful
    astSubscription Incoming Text: HTTP/
    1.1 200 OK


    astSubscription Incoming Text: CONTENT-LENGTH: 
    0
    astSubscription Incoming Text: 
    SERVER: KnOS/3.2 UPnP/1.0 DMP/3.5
    astSubscription Incoming Text: SID: uuid:1810bfe0-5f04-
    1833-a4df-2890685b609c
    astSubscription Incoming Text: TIMEOUT: Second-
    300
    astSubscription Incoming Text:
    astSubscription Acknowledging HTTP/
    1.1 200 OK

    Content-Length: 
    0



    astSubscription_Terminated; Closing astSubscription & socSubscription
    ++++++++++++++++++++++++++


    Transport State has changed:
    NO_MEDIA_PRESENT
    ++++++++++++++++++++++++++


    CurrentURI has changed:
    === Old Value:
    === New Value:
    Set Track loaded: 
    false
    ++++++++++++++++++++++++++
    NextURI has changed:
    === Old Value:
    === New Value:
    Set NextTrack loaded: 
    false
    java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: length=
    90; index=-1
        at anywheresoftware.b4a.keywords.Common$
    5.run(Common.java:965)
        at android.os.Handler.handleCallback(Handler.java:
    615)
        at android.os.Handler.dispatchMessage(Handler.java:
    92)
        at android.os.Looper.loop(Looper.java:
    137)
        at android.app.ActivityThread.main(ActivityThread.java:
    4895)
        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:
    994)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    761)
        at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: length=
    90; index=-1
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    213)
        at anywheresoftware.b4a.keywords.Common$
    5.run(Common.java:962)
        ... 
    9 more
    Caused by: java.lang.ArrayIndexOutOfBoundsException: length=
    90; index=-1
        at java.util.ArrayList.remove(ArrayList.java:
    401)
        at anywheresoftware.b4a.debug.Debug.PopSubsStack(Debug.java:
    156)
        at b4a.themusicmachine.tmm_flipflop._astevents_newtext(tmm_flipflop.java:
    214)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
    511)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    187)
        ... 
    10 more
    The app fails at the first "java.lang.RuntimeException. The common item in all the failures is that first line "ArrayIndexOutOfBoundsException: length=90; index=-1" which repeats three times in the log, and appears exactly like that every time I run the app. It looks like a string function indexing problem but I have been unable to identify it.

    I don't know if it would help if I could look at the "... 9 more" lines or the "... 10 more lines."
    Can anyone tell me how to look at those additional lines?
    Does anyone have any insight into the debug messages based on their knowledge of java that might help identify what is the root cause?
    How can I relate the line numbers (e.g. "java:965") to the actual line numbers in my code?

    Any help would be appreciated ... this is driving me crazy!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why don't you use the rapid debugger?

    Are you running any code in a background thread? The debugger doesn't support it.
     
  3. GuyBooth

    GuyBooth Active Member Licensed User

    When you say "Doesn't support it" does that mean the debugger may CAUSE it to crash?

    I'm not specifically calling for code in the background. I AM running httputils2, AsyncStreamsText, Sockets and ServerSockets in foreground services.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    All of B4A standard libraries do not execute any B4A code in a background thread so they will not cause this problem.

    They do execute native code in the background. But the event is raised on the main thread.

    If you are using the Threading library then you will encounter this error.
     
    lemonisdead likes this.
  5. GuyBooth

    GuyBooth Active Member Licensed User

    I'm not using the threading library.
    As far as I can tell the problem is showing up while I am parsing the results from the AsyncStreamsText class attached to a ServerSocket.
    But why only with the legacy debugger? Why only 90% of the time?
    None of the items being "fed" to the parsing routine are 90 characters long, so why the reference to "length=90; index=-1"?

    Also back to one of my original questions - how do I see the "... 9 more" lines or the "... 10 more lines." in the log?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You cannot see them and it will not help.

    Why don't you use the rapid debugger?
     
  7. GuyBooth

    GuyBooth Active Member Licensed User

    OK.

    I do use the rapid debugger most of the time, but I still have the question of why the legacy debugger is showing an error and the rapid debugger is not?
    Do I have a problem with my code, or is the legacy debugger itself causing a crash?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The error itself happens in the legacy debugger code. If it works with the rapid debugger and in release mode then you can ignore it.
     
  9. GuyBooth

    GuyBooth Active Member Licensed User

    Thank you Erel, that answers my questions.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice