Android Question Starter Service causing crash

Shivito1

Active Member
Licensed User
When I add Starter service my app crash with the following.
B4X:
java.lang.RuntimeException: Unable to create service com.subreaderFree.starter: java.lang.RuntimeException: java.io.EOFException
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3541)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1729)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.io.EOFException
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:165)
    at com.subreaderFree.starter.onCreate(starter.java:47)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3531)
    ... 8 more
Caused by: java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:267)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:335)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    ... 10 more
I am adding this service to an existing program.
 

Widget

Well-Known Member
Licensed User
Longtime User
If you are running in debug mode, you may have a breakpoint in either the Starter service_create sub or in a sub that is called from the starter Service_Create sub.
Delete the breakpoint and use "Tools > Clean Project" then re-run the app.

You can also run in Release mode or use "Tools > IDE Options > Legacy Debugger" to see if that makes a difference.
 
Upvote 0

Shivito1

Active Member
Licensed User
My app will crash in Debug and Release. I am just reading your reply and will update later after I have tried the suggestions.
 
Upvote 0

Shivito1

Active Member
Licensed User
It is fine to put breakpoints in service_create.

Such errors might be related to code in Process_Globals doing something that it shouldn't.
Process_Globals:
B4X:
    Dim jav As List
   
    Dim vidplaying As String
   
    ' video player

    Private player1 As SimpleExoPlayer
   
    Dim Layoutset As String
   
    Dim Timer0 As Timer
    Dim whileplaying As Timer
    whileplaying.Initialize("whileplaying", 50)
    Dim TTS1 As TTS
    Dim encoding As String
    Dim jav As List
   
    Dim langspin As Int
   
    Dim SubTextLabelservice As String
   
    Dim chosenName1 As String
   
    Dim encospinpath As String
    Dim    encospinfile As String
   
    Dim List0, SRTime0 As List
    Dim subTitleList As List
    Dim oddval As Int
    oddval = 0
    Dim Position As Int = 0
    Dim StringFunctions0 As StringFunctions
   
    Dim CurrentTimeLabelservice As String
    Dim CurrentTimeLabel2service As String
   
    Dim CurrentSubTitle As Int = 0 'index -1 from SRT
   
    Dim TimeSeekBarservice As Int
   
    'Dim lastTickTime As Long = 0
    Dim timeStarted As Long = 0
    Dim timeOffset As Long = 0
   
    Dim isPlaying As Boolean = False

   
    Dim subspinnerint As Float
    subspinnerint = 10.0

    Dim SubNumberLabelservice As String
   
    '    Dim spnrLanguages As Spinner
    '  ############SubGitter Globals
    Dim my_buffer As OutputStream
    Dim js As jSoup

    Dim html, local_html, url As String
   
    Dim DOM1 As List : DOM1.Initialize
    Dim DOM2 As List : DOM2.Initialize
    Dim DOM3 As List : DOM3.Initialize
    Dim Selector1 As List : Selector1.Initialize
    Dim Selector2 As List : Selector2.Initialize
    Dim Selector3 As List : Selector3.Initialize
    Dim Extract1 As List : Extract1.Initialize
    Dim Extract2 As List : Extract2.Initialize
    Dim Extract3 As List : Extract3.Initialize
    Dim Extract4 As List : Extract4.Initialize
    Dim Extract5 As List : Extract5.Initialize
   
    Dim selectionurl As String
   
    Dim success1 As String = "false"
   
    DisableStrictMode
   
    Dim Positionset As Int
    Dim selection1 As Int
    Dim DLlink As List : DLlink.Initialize
    selection1 = 0
    Dim searchent As String


    Dim homeclick As Int

   
    '###Lang timer
    Dim setval As Int
    setval = 0
    Dim currentsubval As Int
   
    '### List position for Extr 4
    Dim getindex As List
   
    'Video player
    Private SimpleExoPlayerView1 As SimpleExoPlayerView
    Dim p As Phone
    Dim sources As List
    Dim vidon As String
    vidon = 0

   
    '# Keep screen awake
    Dim wakein As PhoneWakeState
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
Try commenting out the call to "DisableStrictMode" to see if that helps.

Another suggestion is to put in Log() statements every few lines to see if you can narrow down the part of the code that is causing the problem. Start with the first and last lines just to confirm the problem is in this sub.
 
Upvote 0

Shivito1

Active Member
Licensed User
lol I'll try but I remember putting that in because something else was not working haha
 
Upvote 0

Shivito1

Active Member
Licensed User
lol I'll try but I remember putting that in because something else was not working haha
Okay, making progress
I'll probably open a new thread and list the issue and resolution but here is the new Error:
B4X:
java.lang.RuntimeException: Unable to start service b4a.example.standout@68a2159 with Intent { cmp=com.subreaderFree/b4a.example.standout launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3755)
    at android.app.ActivityThread.-wrap23(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1744)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:216)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at b4a.example.standout.handleStart(standout.java:113)
    at b4a.example.standout.onStartCommand(standout.java:81)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3738)
    ... 8 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at b4a.example.standout._init_elements(standout.java:314)
    at b4a.example.standout._service_start(standout.java:552)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    ... 12 more
Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@a3caaa3 -- permission denied for window type 2002
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:921)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:97)
    at b4a.example.standout$CustomImageView.sharedConstructing(standout.java:633)
    at b4a.example.standout$CustomImageView.<init>(standout.java:604)
    at b4a.example.standout.newInstance2(standout.java:771)
    ... 18 more
** Service (standout) Create **
java.io.FileNotFoundException: icon.png
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:423)
    at android.content.res.AssetManager.open(AssetManager.java:397)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:202)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:500)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at b4a.example.standout._service_create(standout.java:479)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at b4a.example.standout.onCreate(standout.java:66)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3531)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1729)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
java.lang.RuntimeException: Unable to create service b4a.example.standout: java.lang.RuntimeException: java.io.FileNotFoundException: icon.png
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3541)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1729)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6780)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: icon.png
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:216)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at b4a.example.standout.onCreate(standout.java:66)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3531)
    ... 8 more
Caused by: java.io.FileNotFoundException: icon.png
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:423)
    at android.content.res.AssetManager.open(AssetManager.java:397)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:202)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:500)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at b4a.example.standout._service_create(standout.java:479)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
    ... 11 more

I'm trying to use Floating Button https://www.b4x.com/android/forum/threads/sd-floating-button-standout.80847/#content
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…