Android Question Running the application in debug mode

Sergey_New

Well-Known Member
Licensed User
Longtime User
The first time you run the application in debug mode on the emulator, an error occurs:
Cannot start from a receiver in debug mode.
java.lang.RuntimeException: Unable to create service sv.bystrovzorov.starter: java.lang.RuntimeException: java.io.EOFException
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2887)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: java.io.EOFException
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
at sv.bystrovzorov.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
... 8 more
Caused by: java.io.EOFException
at libcore.io.Streams.readFully(Streams.java:83)
at java.io.DataInputStream.readInt(DataInputStream.java:103)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
... 12 more
--------- beginning of crash
There is no error when restarting. This is repeated constantly.
In release mode, the error never occurs.
How to fix?
 
Last edited:

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thank you!
Too bad it happens all the time :(
P.S. It is not clear what is the network here? Everything is on one computer.
 
Last edited:
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
First step is to test it with a real device.
Checked through USB and Bridge. Same error when first run in debug mode.
java.lang.RuntimeException: Unable to create service sv.bystrovzorov.starter: java.lang.RuntimeException: java.net.SocketException: Socket closed
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3554)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.RuntimeException: java.net.SocketException: Socket closed
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
at sv.bystrovzorov.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
... 8 more
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:139)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:288)
at java.io.BufferedInputStream.read(BufferedInputStream.java:347)
at java.io.DataInputStream.readFully(DataInputStream.java:198)
at java.io.DataInputStream.readInt(DataInputStream.java:389)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
... 12 more
Made a simple example - it works without error.
Obviously a mismatch in my application. How to find where the error is hidden?
 
Last edited:
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Started debugging with the filter turned off. The application opened with a slight delay.
Can this say something?
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
code in starter service
Starter:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
'    #StartCommandReturnValue: android.app.Service.START_STICKY
#End Region

Sub Process_Globals
    Type ClassNote(text As String)
    Type fact(sort As Long, id As String, date As String, fact As String, data As String, sex As String)
    Type KeyValue(key As String,value As String)
    Type KeyNumber(key As Int, value() As String)
    Type record(c1 As Int, c2, c3, parent, clas As String)
    Type ClassSubmitter(addr, name, phon, fax, email, www As String)
    Dim pm As PackageManager
    Public Provider As FileProvider
    Public loc As Localizator
    Dim availableLang As List
    Dim tf As Typeface=Typeface.DEFAULT
    Dim MainPerson, LanguageI, gedFileName, myFolder, ProgVersion, DateFormat="dd.MM.yyyy", _
    SelectedEvents="BIRT,MARR,DEAT", ProgName, Religious="orthodox", SelectedReligious="Пасха,Троица,Вознесение" As String
    Dim scale, TextSize, TextSizeMin As Float
    Dim lbHeight, MySize(), TextColor=Colors.Black, myWidth As Int
    Dim LoadLastFile, IsChanged, OneClick, UnknowTag, hint, Notificat As Boolean
    Dim mapSettings, options As Map
    Public NextTime=9 As Double
End Sub

Sub Service_Create
    Provider.Initialize
End Sub

Sub Service_Start (StartingIntent As Intent)
    ProgVersion=pm.GetVersionName("sv.bystrovzorov")
'    VersionCode=pm.GetVersionCode("sv.bystrovzorov")
    ProgName=pm.GetApplicationLabel("sv.bystrovzorov")
    myWidth=GetDeviceLayoutValues.Width
    scale=GetDeviceLayoutValues.Scale
    Select Case scale
        Case 1                        'GetDeviceLayoutValues.height=432  w=320    240x320
            TextSizeMin=12
        Case 1.5                    'HTC Desire 310 4,5″ 480x854
            TextSizeMin=13
        Case 2                        'GetDeviceLayoutValues.height=1184 w=720    4,7″ 720x1280 HTC ONE X TextSize: 13-15-17
            TextSizeMin=14
        Case 3                        'GetDeviceLayoutValues.height=2560 w=1440    5,1″ 1440x2560 Samsung Galaxy S7 (G930F) TextSize: 14-16-18
            TextSizeMin=15
        Case 4
            TextSizeMin=16
        Case Else
            TextSizeMin=17            'GetDeviceLayoutValues
    End Select
    mapSettings.Initialize
    availableLang.Initialize
    SetOptions
    If File.Exists(File.DirInternal, ProgName & ".ini")Then
        ReadIni
    Else
        File.WriteMap(File.DirInternal, ProgName & ".ini", options)
        ReadIni
    End If
    Dim t As Int=TextSize-TextSizeMin
    Dim w As Int=65dip+(t)*8* scale '169-3*ts*Main.scale)
    Dim h As Int=40dip+(t)*4* scale
    MySize= Array As Int(w,h)
End Sub

Sub SetOptions
    options.Initialize
    options.Put("TextSize", TextSizeMin)
    options.Put("LoadLastFile", LoadLastFile)
    options.Put("gedFileName", gedFileName)
    options.Put("LanguageI", LanguageI)
    options.Put("DateFormat", DateFormat)
    options.Put("hint", hint)
    options.Put("OneClick", OneClick)
    options.Put("UnknowTag", UnknowTag)
    options.Put("SelectedEvents", SelectedEvents)
    options.Put("SelectedReligious", SelectedReligious)
    options.Put("SelectedTime", NextTime)
    options.Put("Religious", Religious)
End Sub

Sub ReadIni
    mapSettings = File.ReadMap(File.DirInternal, ProgName & ".ini")
    For Each key As String In options.Keys
        If mapSettings.ContainsKey(key) Then
            options.Put(key,mapSettings.Get(key))
        End If
    Next
    mapSettings=options
    TextSize=mapSettings.Get("TextSize")
    LoadLastFile=mapSettings.Get("LoadLastFile")
    gedFileName=mapSettings.Get("gedFileName")
    hint=mapSettings.Get("hint")
    OneClick=mapSettings.Get("OneClick")
    UnknowTag=mapSettings.Get("UnknowTag")
    LanguageI=mapSettings.Get("LanguageI")
    Religious=mapSettings.Get("Religious")
    Dim s As String=mapSettings.Get("SelectedEvents")
    SelectedEvents=s
    Dim r As String=mapSettings.Get("SelectedReligious")
    SelectedReligious=r
    If s.Length+r.Length>0 Then Notificat=True
    NextTime=mapSettings.Get("SelectedTime")
    loc.Initialize(File.DirAssets, "strings.db")
    function.setPrefix
End Sub

Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Erel, thank you for your participation!
I keep looking for reasons.
In the debug log without a filter, I found the following lines:
B4X:
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
skipped assignment of: public sv.bystrovzorov.classsource$_sourceevent sv.bystrovzorov.datasource._event
skipped assignment of: public sv.bystrovzorov.classsource$_sourceevent sv.bystrovzorov.datasource._event
** Activity (main) Resume **
At the same time, no actions were taken with the classsource class.
What can be wrong in this class and can it affect the debug mode?
B4X:
Sub Class_Globals
    Public titl, abbr, text, publ, auth, mediatype, repo, caln As String, data As sourcedata, notes, media As List
    Type sourcedata(agen As String, events As List)
    Type sourceevent(even, date, place As String)
End Sub
Public Sub Initialize
    data.Initialize
    data.events.Initialize
    notes.Initialize
    media.Initialize
End Sub
 
Upvote 0
Top