Person Reports Weird Error

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
One person using one of my apps on an HTC Incredible reports getting the following error upon opening the app:

"An error has occurred in Sub:main_build_cyclist (Javaline(976):java.lang.RuntimeException: Object should first be initialized."

I think "Sub:main_build_cyclist" is the key to finding out more about this error, but there is nothing in my code similar to this, and Google searches turn up nothing.

I don't get this error when testing on any of my devices. Do you have any idea what this error is and what may be causing it?

Thanks,
Barry.
 

dagnabitboy

Active Member
Licensed User
Longtime User
I believe you can look at the java code the compiler creates. Look in the output folder for your program under objects/src/com/xxx/programName. Substitute your values for xxx and programName of course. Then in the java file find line 976. that may give you a clue to the problem.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
I believe you can look at the java code the compiler creates. Look in the output folder for your program under objects/src/com/xxx/programName. Substitute your values for xxx and programName of course. Then in the java file find line 976. that may give you a clue to the problem.

Thank you – very good suggestion. Here is the contents of the source file around line 976: (I added the line numbers - they could not be copied)

B4X:
968   public static String  _buildcomiclist() throws Exception{
969   String _qry = "";
970   int _i = 0;
971   int _rc = 0;
972   int _rid = 0;
973   anywheresoftware.b4a.sql.SQL.CursorWrapper _cssql = null;
974    //BA.debugLineNum = 350;BA.debugLine="Sub BuildComicList ' Built list of comics where state = t";
975    //BA.debugLineNum = 351;BA.debugLine="Dim qry As String";
976   _qry = "";
977    //BA.debugLineNum = 352;BA.debugLine="Dim i, rc, rid As Int";
978   _i = 0;
979   _rc = 0;
980   _rid = 0;
981    //BA.debugLineNum = 353;BA.debugLine="Dim csSQL As Cursor";
982   _cssql = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
983    //BA.debugLineNum = 355;BA.debugLine="qry = \"SELECT rowid, state, title, url FROM csho WHERE state = 't' ORDER BY title\"";

If you assume the person told me the subroutine name incorrectly – it is too close to be a coincidence, this looks like the proper area.

Any idea why this code would give a problem on a specific device, HTC Incredible? Could it be an out of memory error?

Barry.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
are you directed to this subroutine when clicking a button? if yes, check if this error appears when a user clicks twice and very fast this button. just a thought...
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
are you directed to this subroutine when clicking a button? if yes, check if this error appears when a user clicks twice and very fast this button. just a thought...

Thanks, but nope.

This subroutine is called at the end of Activity_Create as part of the initialization. According to the person who reported the error, the application never "shows", but almost immediately opens to a black screen with this error message.

If the error line number is correct, the error occurs when a string variable is initialized. I believe strings, in Java, are dynamic so this assignment might possibly cause memory to be allocated for the string variable "qry" – just a guess.

The B4A source code that corresponds to the Java code I listed earlier is:
B4X:
Sub BuildComicList ' Built list of comics where state = t
  Dim qry As String
  Dim i, rc, rid As Int
  Dim csSQL As Cursor
  
  qry = "SELECT rowid, state, title, url FROM csho WHERE state = 't' ORDER BY title"

Barry.
 
Last edited:
Upvote 0

BarrySumpter

Active Member
Licensed User
Longtime User
Try changing the 't' to 123 and compile.
If no error then you know it the 't'.

Otherwise, start with deductive reasoning,
i.e. comment out the entire line and compile.
If no error then you know it the line.

If you still get an error then comment out the bottom half
of the script n compile, etc.

Otherwise, you'll have to File | Export as zip
to post the project so we can have a look.

hth
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Try changing the 't' to 123 and compile.
If no error then you know it the 't'.
...

Thanks. But, I don't think the problem has to do with the SQL statement or actual query. This works on my test devices and dozens of other devices people are using.

Unfortunately, I'm not able to debug or research the problem on his device any further since I have no contact with this person other than the e-mail notifying me of the error on his device.

The error line number, if it's accurate, points to the statement " qry = "" ". This is part of the initialization in conjunction with the "Dim" within B4A. The error suggests "something is not initialized".

Of course, it could be that I have an error that just happens to work on many devices – that's happened before. I will add your suggestions to the things I investigate.

Barry.
 
Upvote 0

BarrySumpter

Active Member
Licensed User
Longtime User
Perhaps find out what version of android he is using and create a simulator for that version and test on that simulator.
 
Last edited:
Upvote 0
Top