Android Question Debugger problem

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Every so often when I start a Compile & Run (background) I get a message like this:
B4X:
An error occurred: 
(Line: 139) Sub Activity_Resume
java.lang.IndexOutOfBoundsException: index 4
** Activity (main) Resume **

And I restart the app and sometimes I will get this tow or 3 times in a row and then everything is fine for a bunch of Compile and Runs then it happens again. The Log (without the filters shows nothing)

BobVal
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Hasn't happened while using USB debugging only when using Wireless

Not sure how to see or get you the logs without USB debugging.

I have had this happen in other program I wonder if it is my Main causing it?
I normally have a Menu of buttons and when a buttons is pressed start another activity
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
	
    Activity.LoadLayout("sGolfScore")
	Activity.Title = "Main Menu"

	If FirstTime Then
	   cColors.Initialize
	   cGenFuncs.Initialize
	   cDatabase.Initialize
	End If
	
End Sub

Sub Activity_Resume

    cDatabase.OpenDB(False)

    CreateScreen
	
End Sub 

Sub Activity_Pause (UserClosed As Boolean)
    If  UserClosed Then
        cDatabase.CloseDB

        ExitApplication
    End If
End Sub

Sub CreateScreen
	sGolfScore_Main.Left     = 0
    sGolfScore_Main.Top      = 0	
	sGolfScore_Main.Width    = 100%x
	sGolfScore_Main.Height   = 100%y
	
	PositionButton(sAdd_Modify_Courses,                                                              75dip, 40dip, -1,    -1)
	PositionButton(sAdd_Modify_Players,     (sAdd_Modify_Courses.Top + sAdd_Modify_Courses.Height) + 25dip, 40dip, -1,    -1)
	PositionButton(sAdd_Modify_Rounds,      (sAdd_Modify_Players.Top + sAdd_Modify_Players.Height) + 25dip, 40dip, -1,    -1)

	PositionButton(sPlayer_ScoreCards,       sAdd_Modify_Rounds.Top                                       , -1,    40dip, -1)
	PositionButton(sPlayer_Stats,           (sPlayer_ScoreCards.Top  + sPlayer_ScoreCards.Height)  + 25dip, -1,    40dip, -1)

	PositionButton(sContinue_CurrentRound,  -1,                                                             (100%x-sContinue_CurrentRound.Width)/2,    -1,    75dip)		
End Sub

Sub PositionButton(ThisButton As Button, Top As Int, FromLeft As Int, FromRight As Int, FromBottom As Int)

    If Top        <> -1 Then ThisButton.Top  = Top
	If FromLeft   <> -1 Then ThisButton.Left = FromLeft
	If FromRight  <> -1 Then ThisButton.Left = sGolfScore_Main.Width  - (FromRight  + ThisButton.Width)
	If FromBottom <> -1 Then ThisButton.Top  = sGolfScore_Main.Height - (FromBottom + ThisButton.Height)
End Sub

Sub sAdd_Modify_Courses_Click           :    StartActivity("aCourses")              :    End Sub
Sub sContinue_CurrentRound_Click        :    StartActivity("aPlayerScoring")        :    End Sub

aCourses and aPlayerScoring are other Activity programs.

The App is big. I will see if I can find something on our forums on how to get the logs when not using USB.

NOTE: I am not (have not even tried) very good with any of the Android stuff. I just us the B4A environment entirely

BobVal
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I sure hope this is what you need.

As you will see below my App crashed and when I restart it and selected one of my menu items I get the error (I tried twice and on the 3rd time the app ran fine)

Only have seen this when using the Bridge to debug

B4X:
LogCat connected to: B4A-Bridge: samsung SM-T210-
--------- beginning of /dev/log/main
loaded /system/lib/egl/libEGL_MRVL.so
loaded /system/lib/egl/libGLESv1_CM_MRVL.so
loaded /system/lib/egl/libGLESv2_MRVL.so
<tid=3166> OES20 ===> GC Version   : GC Ver-988-JB-R4-RC2-GC18 
Enabling debug mode 0
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
GC_CONCURRENT freed 206K, 16% free 7588K/8967K, paused 11ms+13ms, total 51ms
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Streams_terminated
Connected to B4A-Bridge (Wifi)
GC_CONCURRENT freed 392K, 17% free 7739K/9287K, paused 12ms+2ms, total 42ms
WAIT_FOR_CONCURRENT_GC blocked 24ms
Installing file.
** Activity (main) Pause, UserClosed = false **
GC_CONCURRENT freed 563K, 19% free 7630K/9415K, paused 13ms+15ms, total 106ms
PackageAdded: package:com.Bobs.GolfScore
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (acourses) Create, isFirst = true **
** Activity (acourses) Resume **
*******************************
***  Courses CreateScreen
***
***  ScreenX:600  ScreenY:943
*******************************
AttachTo - L:137 T:6 W:344 H:35
AttachTo - L:137 T:6 W:306 H:35
cDropDown List Entry:Lake Gaston  Pos:1
**************************
***  Courses ShowCourse
**************************
**************************
***  Courses ShowGrids
**************************
RatingsSlopeGrid  Left:5 Top:152 Width:590 Height:139
sCourses_HandicapYardsPar_Grid  Left:5 Top:284 Width:590 Height:654
**********************
***  cGrid ShowGrid
**********************
SV2D.Top:46  SV2D.Height:94
SV2D.Position:0  SV2D.Panel.Height:89
VSV.Top:46  VSV.Height:94
VSV.Position:0  VSV.Panel.Height:89
mCourses_RatingsSlope_Grid - GridWindow.Height:139  FixColsPanel.Height:46  VertScroll.Height:94
==========================
===  cGrid End-ShowGrid
==========================
**********************
***  cGrid ShowGrid
**********************
SV2D.Top:46  SV2D.Height:609
SV2D.Position:0  SV2D.Panel.Height:1
VSV.Top:46  VSV.Height:609
VSV.Position:0  VSV.Panel.Height:1
mCourses_HandicapYardsPar_Grid - GridWindow.Height:654  FixColsPanel.Height:46  VertScroll.Height:609
==========================
===  cGrid End-ShowGrid
==========================
RatingsSlopeGrid  Left:5 Top:152 Width:590 Height:139
sCourses_HandicapYardsPar_Grid  Left:5 Top:284 Width:590 Height:654
==========================
===  Courses End-ShowGrids
==========================
GC_CONCURRENT freed 415K, 19% free 7639K/9415K, paused 12ms+2ms, total 24ms
**********************
***  cGrid ShowGrid
**********************
SV2D.Top:46  SV2D.Height:609
SV2D.Position:0  SV2D.Panel.Height:925
VSV.Top:46  VSV.Height:609
VSV.Position:0  VSV.Panel.Height:925
mCourses_HandicapYardsPar_Grid - GridWindow.Height:654  FixColsPanel.Height:46  VertScroll.Height:609
==========================
===  cGrid End-ShowGrid
==========================
==========================
===  Courses End-ShowCourse
==========================
=================================
=== Courses End CreateScreen
=================================
ClickTime:233
Touch Click for EditText
Touch Click for EditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:false  New: Old:
  FocusChanged:true  FocusChangeStatus:true
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:68. Old:68.8
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:68 Old:68.
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:6 Old:68
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
GC_CONCURRENT freed 429K, 19% free 7639K/9415K, paused 2ms+2ms, total 14ms
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New: Old:6
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:7 Old:
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:70 Old:7
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:70. Old:70
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:false
  DataValid:true  New:70.1 Old:70.
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
RowID:1  ColID:1
  EnterPressed:true
  DataValid:false  New: Old:
  FocusChanged:false  FocusChangeStatus:false
  Ending:false
There is an ActiveEditText
Error occurred on line: 1184 (cgrid)
java.lang.RuntimeException: Object should first be initialized (EditText).
	at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
	at anywheresoftware.b4a.objects.EditTextWrapper$3.onFocusChange(EditTextWrapper.java:119)
	at android.view.View.onFocusChanged(View.java:4642)
	at android.widget.TextView.onFocusChanged(TextView.java:7653)
	at android.widget.EditText.onFocusChanged(EditText.java:178)
	at android.view.View.unFocus(View.java:4563)
	at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3697)
	at android.view.ViewGroup.removeViewAt(ViewGroup.java:3661)
	at anywheresoftware.b4a.objects.PanelWrapper.RemoveViewAt(PanelWrapper.java:83)
	at com.Bobs.GolfScore.cgrid._cgrid_edittext_enterpressed(cgrid.java:2665)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
	at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:305)
	at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
	at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
	at anywheresoftware.b4a.objects.EditTextWrapper$2.onEditorAction(EditTextWrapper.java:107)
	at android.widget.TextView.onEditorAction(TextView.java:4219)
	at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138)
	at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:297)
	at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4949)
	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:1043)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
	at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
(Intent) Intent { act=android.intent.action.MAIN flg=0x20000000 cmp=com.Bobs.GolfScore/.main }
no extras
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
GC_CONCURRENT freed 393K, 19% free 7633K/9415K, paused 1ms+2ms, total 13ms
** Activity (main) Pause, UserClosed = false **
** Activity (acourses) Create, isFirst = true **
** Activity (acourses) Resume **
An error occurred: 
(Line: 139) Sub Activity_Resume
java.lang.IndexOutOfBoundsException: index 4
** Activity (main) Resume **
(Intent) Intent { act=android.intent.action.MAIN flg=0x20000000 cmp=com.Bobs.GolfScore/.main }
no extras
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (acourses) Create, isFirst = true **
** Activity (acourses) Resume **
An error occurred: 
(Line: 139) Sub Activity_Resume
java.lang.IndexOutOfBoundsException: index 4
** Activity (main) Resume **
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
EditText code below

B4X:
    Type  TGridRectangle(Left As Int, Top As Int, Width As Int, Height As Int)

    Type  TGridRowAnchor(RowID As Int, Height As Int)
	
	Type  TGridEvent(CallWho As Object, CallWhat As String)

	Type  TGridEventEditTextExtra(EnterPressed As Boolean, FocusChanged As Boolean, FocusChangedStatus As Boolean, DataValid As Boolean, Old As String, New As String, Ending As Boolean, ActiveET As EditText)	
	Type  TGridEventSpinnerExtra(Position As Int, Item As String)
	
	Type  TGridEventParameter(RowID As Int, ColID As Int, Extra As Object)
	
    Type  TGridSystemInfo(RowID As Int, ColID As Int, Fixed As Boolean, RowHeight As Int, ColumnInfo As TGridColumnInfo, Routines As List, Frame As Panel, Display As Object, Cover As Label, Event As TGridEvent)

    Type  TGridRoutine(RowID As Int, ColID As Int)

    Type  TGridColumnInfo(ColumnName As String, DisplayText As String, ColumnType As Int, Width As Int, Format As TGridColumnFormat, Function As TGridFunction)

    Type  TGridColumnColors(FGColor As Int, BGColor As Int, SpacingColor As Int)
    Type  TGridColumnFormat(ColumnColors As TGridColumnColors, FontSize As Int, Format As Int, FontTypeFace As Typeface)

    Type  TGridFunction(Function As Int, Range() As TGridFunctionRange)
    Type  TGridFunctionRange(StartRow As Int, EndRow As Int, StartCol As Int, EndCol As Int)

B4X:
Sub cGrid_EditText_EnterPressed	

    If mInCreateEditText OR mInShowGrid Then Return
	
	If (Sender Is EditText) = False Then Return
	
	
    Dim SentFrom      As EditText        = Sender
    Dim Column        As TGridSystemInfo = SentFrom.Tag
    Dim Display       As Label           = Column.Display

    Dim ExtraEvents   As TGridEventEditTextExtra
	
	ExtraEvents.Initialize
	ExtraEvents.EnterPressed       = True
	ExtraEvents.FocusChanged       = False
	ExtraEvents.FocusChangedStatus = False
	ExtraEvents.DataValid          = False
	ExtraEvents.New                = ""
	ExtraEvents.Old                = ""
    ExtraEvents.ActiveET           = mActiveEditText
	ExtraEvents.Ending             = False
	
	EditText_Events(Column, ExtraEvents)

	Dim ETObject     As EditText   = Column.Frame.GetView(Column.Frame.NumberOfViews-1)

    If ETObject Is EditText Then
	   Dim ETField   As EditText  = ETObject
	
	   Display.Text    = ETField.Text
	
	   Column.Frame.RemoveViewAt(Column.Frame.NumberOfViews-1)
	   
	   HideKeyboard
	   
	   mActiveEditText = Null	   
	End If
End Sub
 
Upvote 0
Top