Java Null Pointer ERROR

pbmjoe

Member
Licensed User
Longtime User
The attached Sudoku Solver code compiles in V2.5 B4A with no errors.
The Solver operates correctly until the following sequence of operations.
Select the last Puzzle.
From the Menu select Delete and confirm Deletion.
Close the Solver.
Re-open the Solver and the Java Null Pointer error will appear.
However, the last Puzzle is deleted correctly and the Puzzle file is OK
If an intermediate Puzzle is deleted no Error occurs.

The Delete last puzzle code is as follows.
Each Puzzle takes 200 Bytes of data
cpuz is the current Puzzle number

Dim Ftext, TT as string
Dim cpuz as int
Ftext = File.ReadString(File.DirRootExternal,"Puzzels.txt")
TT = Ftext.SubString2(0,(cpuz - 1)* 200)

File.Delete(File.DirRootExternal,"Puzzels.txt")

File.WriteString(File.DirRootExternal,"Puzzels.txt",TT)

The Puzzle deletion code appears to set up the error condition which causes the
Solver to fail in the second activation.
I would Appreciate any suggestions that could help to fix this problem.

pbmjoe

:sign0085:
 

Attachments

  • NewSudoku.apk
    113 KB · Views: 146
  • JavaError.jpg
    JavaError.jpg
    47.4 KB · Views: 169

pbmjoe

Member
Licensed User
Longtime User
I have Run the code in debug mode and checked the log.
The error occurs in java line 1230
This must point to the compiled code
How do I at the High B4A level find and fix this problem?
I have confirmed that the error occurs in the code sample provided in the original Post. Is there an obvious error in this code?
Regards
pbmjoe
 
Upvote 0

pbmjoe

Member
Licensed User
Longtime User
(Solved) Java Null Pointer ERROR

(Solved) Java Null Pointer ERROR
Solved thanks to Erel.
This error does not occur in the initial use of the Solver App.
It occurred when the Solver was closed using the Back key and then immediately reopened using the Solver Icon.
I could not see any way of locating the cause of this error.
After reading the Post from Erel I carried out the following procedure.

Connect a Galaxy Note Phone to B4A using Bluetooth.
Select the Debug option (No break points set rely on the error to stop the Debugger)
Compile and run.
Install and run on the Phone.
Press the Back key on the Phone.
Reopen the Solver using the Phone icon.
The “Java Null Pointer ERROR” occurred.
The B4A Debugger stopped at the error, the Log showed a long list of b4a......... java statements.
These did not mean much to me; however, the Debug window displayed a list of variables up to the Error.
The reason for the error was then obvious.
It appears that the Break Key does not Kill and Application and if the App is immediately reopened it will continue as if the break had not occurred. In my case all the variables were correct except one and this caused the error.
I am not sure why this variable was corrupt but I can now check for this in my B4A code.
Thanks again Erel
pbmjoe
 
Upvote 0
Top