Android Question App wont run...error Application stopped

raphipps2002

Active Member
Licensed User
Longtime User
Ive been developing an app, compiling and running just fine. But suddenly I have this error show below which I cannot fathom! Can anyone explain its meaning to me? And how I might fix it?

Installing file.
PackageAdded: package:b4a.KCS
java.lang.RuntimeException: Unable to create service b4a.KCS.starter: java.lang.RuntimeException: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3661)
at android.app.ActivityThread.access$2000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1759)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.RuntimeException: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:163)
at b4a.KCS.starter.onCreate(starter.java:46)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3651)
... 9 more
Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:592)
at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
at java.io.InputStream.read(InputStream.java:162)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
at java.io.BufferedInputStream.read(BufferedInputStream.java:234)
at java.io.DataInputStream.readByte(DataInputStream.java:75)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:330)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:244)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
... 11 more
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:185)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
... 23 more
 

JonPM

Well-Known Member
Licensed User
Longtime User
It might be either a server-side problem, or a problem with the way you are connecting with a server. CAn you show your connection and download code?
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
hmm thats odd. All I am doing is creating a SQL DB in the file.dirDefaultExternal directory....what is really odd is all was working and then I selected a photo as an icon and on installation the phone crashed. SOmething to do with 'Touchwiz??' In the end I had to factory reset. I then reinstalled and crashed again. Crashed. Reset. Now the app just stops. Its very strange.

On creation app simply tests in DB exists. Calls a code module 'loadAllData' and either creates table or loads data. simple :(


B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
    Activity.LoadLayout("laymain")
   
    Activity.AddMenuItem("Recipients","recips")
   
   
   
    If File.Exists(File.DirDefaultExternal,loadAllData.sqlName) = False Then
        loadAllData.createtables
    Else
        sql.Initialize(File.DirDefaultExternal,loadAllData.sqlName,False)
        loadAllData.loaddata
    End If
   
     If FirstTime Then
        Gps.Initialize("GPS")
    End If
   
'   
End Sub

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    Dim sqlName As String = "data.db"
   
    Dim Rmap As Map
   
    Dim sql As SQL   

End Sub


Sub createtables
   
    sql.Initialize(File.DirDefaultExternal,sqlName,True)
   
    sql.ExecNonQuery("Create Table rec(name Text, number text, col3 Text, col4 Text, col5 Text)")
   
       
End Sub

Sub loaddata
   
    'Creates a map for all Alerts contacts by reading the SQL file
    sql.Initialize(File.DirDefaultExternal,sqlName,False)
    Dim cursor1 As Cursor
    cursor1 = sql.ExecQuery("Select * from rec")

    Rmap.Initialize
       
    For i = 0 To cursor1.RowCount-1
   
        cursor1.Position = i
   
        Rmap.Put(cursor1.GetString("number"),cursor1.GetString("name"))

        Log(cursor1.GetString("number") & " " & cursor1.GetString("name"))
               
    Next
   
    cursor1.Close
   
   
End Sub



Sub CountRecords As Int

        Dim cursor1 As Cursor
   
        cursor1 = sql.ExecQuery("Select * from rec")
       
        Dim NoOfRec As Int = cursor1.rowcount

        cursor1.close
       
        Return NoOfRec

End Sub


Sub CreateMapOfNumbers As Map


    Dim AllContacts As Contacts2
    Dim ListOfContacts As List
   
    Dim cons As Map
    cons.Initialize()
    Dim M As Map
    M.Initialize()
   
    ListOfContacts = AllContacts.GetAll(True,False)

    For i = 0 To ListOfContacts.Size - 1
   
        Dim C As Contact
        C = ListOfContacts.Get(i)
       
        Dim Nme As String = C.DisplayName
       
        M  = C.GetPhones()
       
        'Need to find mobile number format mobile number and name
        For Each k As String In M.Keys
       
            k = k.Replace(" ","")
            k = k.Replace("+44","07")
       
        '    Log("Amended " & k)
       
            Dim str1 As String
            Try
                str1 = k.SubString2(0,2)
            Catch
                str1 = ""
                Log(LastException)
            End Try
       
            If str1 = "07" Then
                '07730145660,Fred
                cons.Put(k,Nme)
                Log(k & " " & Nme)
       
            End If
       
'           

        Next
    Next       
   

    Return cons   

End Sub
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Where is the DB coming from? Is it downloaded from somewhere? Also are you using a service?
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
Thanks for reply and for looking at this for me. I am not using a starter. The DB is created dynamically as the per last code is sent over as follows: an using the True parameter for the SQL DB

B4X:
Sub createtables
  
    sql.Initialize(File.DirDefaultExternal,sqlName,True)
  
    sql.ExecNonQuery("Create Table rec(name Text, number text, col3 Text, col4 Text, col5 Text)")
  
      
End Sub
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
THIS IS MADNESS! whole problem is this

B4X:
    Dim TopPosOfCOntactsForAlert As Double = PerYToCurrent(1)
'

This was in process globals

Nothing to do with service modules or sql....that all works perfectly....

If I move to Globals is works fine! But surely B4a should come up with an error rather than such a crash with no apparant obvious error..

Perhaps Erel might explain

thanks for your efforts!
 
Upvote 0
Top