Android Question What is anywheresoftware.b4a.BA$SharedProcessBA

Gary Milne

Active Member
Licensed User
Longtime User
I get this error calling DBUtils to do an InsertMap.

java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA$SharedProcessBA anywheresoftware.b4a.BA.sharedProcessBA' on a null object reference

This is the line of code:
B4X:
DBUtils.InsertMaps(Main.DB, "SK_SESSION_MASTER", MapList)

Even if I try to step into the DBUtils module it will crash with the above error. I've placed the call within a Try\Catch and it still crashes.

I've used this same code elsewhere and it works but in this one place it crashes.

Any ideas or pointers as I'm out.
 

DonManfred

Expert
Licensed User
Longtime User
Without seeing your code it is nearly impossible to give congrete advices.
 
Upvote 0

Laurent95

Active Member
Licensed User
Longtime User
I get this error calling DBUtils to do an InsertMap.

java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA$SharedProcessBA anywheresoftware.b4a.BA.sharedProcessBA' on a null object reference
.../...

Hello,
I have a supposed similar error, but only in 'Debug Legacy' mode,
see my post about it -> https://www.b4x.com/android/forum/threads/error-only-in-debug-legacy-mode.58006/

Have you tried in Release or Rapid Debug ?
And indeed without a sample of code or not enough details it's not easy to help.

Regards.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Hello,
I have a supposed similar error, but only in 'Debug Legacy' mode,
see my post about it -> https://www.b4x.com/android/forum/threads/error-only-in-debug-legacy-mode.58006/

Have you tried in Release or Rapid Debug ?
And indeed without a sample of code or not enough details it's not easy to help.

Regards.
I'm using Rapid and did try Release with same result. I don't think it's the code per-se as I use identical code elsewhere to update a different table in the same database. Also, a Try\Catch structure does not catch it. Thanks for taking a look, I was hoping someone would be able to give me a clue about what the error meant.
 
Upvote 0

Gary Milne

Active Member
Licensed User
Longtime User
Without seeing your code it is nearly impossible to give congrete advices.
Thanks for taking a look Don.

Here is the context of the code but it seems like it is not a code issue. If I try and step into the DBUtils.InsertMaps Sub it crashes with the above error.

B4X:
    Sub Write_Session_Master_Record(ShowMessages As Boolean) As Boolean
        'Update the SR based on the content of the SK_SMR
        Dim SuccessFlag As Boolean
        Dim SessionMasterMap As Map
        Dim Result As String
        Dim MyQuery As String
      
        SessionMasterMap.Initialize
        SuccessFlag = False  

        'We do not write the SessionNumber as this is an AutoIncrement Primary Index
        SessionMasterMap.Put("SchemaVersion", Main.SK_SMR.SchemaVersion)
        SessionMasterMap.Put("SessionClosed", Main.SK_SMR.SessionClosed)
        SessionMasterMap.Put("Date", Main.SK_SMR.Date)
        SessionMasterMap.Put("Time", Main.SK_SMR.Time)
        SessionMasterMap.Put("SinglesDoubles", Main.SK_SMR.SinglesDoubles)
        SessionMasterMap.Put("SinglesDoublesDescription", Main.SK_SMR.SinglesDoublesDescription)
        SessionMasterMap.Put("CourtType", Main.SK_SMR.CourtType)
        SessionMasterMap.Put("CourtTypeDescription", Main.SK_SMR.CourtTypeDescription)
        SessionMasterMap.Put("MatchType", Main.SK_SMR.MatchType)
        SessionMasterMap.Put("MatchTypeDescription", Main.SK_SMR.MatchTypeDescription)
        SessionMasterMap.Put("PlayerServesFirst", Main.SK_SMR.PlayerServesFirst)
        SessionMasterMap.Put("PlayerName", Main.SK_SMR.PlayerName )
        SessionMasterMap.Put("PPartnerName", Main.SK_SMR.PPartnerName )
        SessionMasterMap.Put("OpponentName", Main.SK_SMR.OpponentName )
        SessionMasterMap.Put("OPartnerName", Main.SK_SMR.OPartnerName )
        SessionMasterMap.Put("CustomShotsEnabled", Main.SK_SMR.CustomShotsEnabled)
        'SessionMasterMap.Put("Custom1ButtonName", Main.SK_SMR.Custom1ButtonName)
        'SessionMasterMap.Put("Custom2ButtonName", Main.SK_SMR.Custom2ButtonName)
        SessionMasterMap.Put("Custom1ButtonName", "Custom 1")
        SessionMasterMap.Put("Custom2ButtonName", "Custom 2")
      
        SessionMasterMap.Put("CollectPointDetail", Main.SK_SMR.CollectPointDetail)
        SessionMasterMap.Put("CollectStrokeDetail", Main.SK_SMR.CollectStrokeDetail)
        SessionMasterMap.Put("CollectErrorDetail", Main.SK_SMR.CollectErrorDetail)
        SessionMasterMap.Put("CollectPlayerDetail", Main.SK_SMR.CollectPlayerDetail)
        'SessionMasterMap.Put("Comment", Main.SK_SMR.Comment )
        SessionMasterMap.Put("Comment", "This is the comment" )      
        SessionMasterMap.Put("Flags", Main.SK_SMR.Flags )
      
        'DBUtils.InsertMaps requires a list of maps, even for a single entry.
        Dim MapList As List
        MapList.Initialize
        MapList.Add(SessionMasterMap)

        'Write the data to the DB
        'Main.DB.BeginTransaction
        Dim MyDB As SQL
        MyDB.Initialize(Main.Settings.DB_Dir, Main.Settings.DB_Name,False)
        Try
            DBUtils.InsertMaps(MyDB, "SK_SESSION_MASTER", MapList)
            'Main.DB.TransactionSuccessful
            'Now get the new session number that we just created
            MyQuery = "SELECT MAX(SessionNumber) FROM SK_SESSION_MASTER"
            Result = Main.DB.ExecQuerySingleResult(MyQuery)
            If Result <> Null Then
                SessionNumber = Result
                If ShowMessages = True Then ToastMessageShow("Created new session number " & SessionNumber, False)
                SuccessFlag = True
            End If
        Catch
            Log(LastException.Message)
            If ShowMessages = True Then ToastMessageShow("Error creating new session",True)
        End Try
        'Main.DB.EndTransaction
      
        Return SuccessFlag
    End Sub
 
Upvote 0
Top