Android Question ResumableSub into Starter Service crashes?


Active Member
Licensed User
it was my mistake. the library Su was initialized under a conditional piece of code, so it was initialized only in some cases.
Moved Su.initialize in a different place and it works in starter service without problems!


Hello B4A community,
I think I'm doing something wrong with a resumable sub.
I'm implementing a new piece of code In the starter service that make use of a resumable sub.
It works fine calling callsubdelayed(Starter,"checkRoot") from another activity, but crashes running it directly from Starter service.

I tried using callsubdelayed also from Starter or moving the call into the Service_start sub but crashes anyway.

'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Sub Service_Create
    'various code here, already proven to work
    'check if rooted, this is a new piece of code that crashes the app:
End Sub

'check if device is rooted
Sub checkRoot
    'check if rooted, if not then reset also the setting
    If Kvs.Get("superuser_enabled")=True Then Su.Initialize
    'new V5.11 (use updated Supersu library)
    Wait For (Su) RootCheck_Done(rootRes As Int)
    Select Case rootRes
        Case Su.ROOT_TRUE
            LogColor("Main> Device Rooted!", Colors.Green)
        Case Else
    End Select
End Sub

The error is:

*** Service (starter) Create ***
Device locale: it
** Service (starter) Start **
starter$ResumableSub_checkRootresume (java line: 305)
java.lang.NullPointerException: Attempt to read from field 'java.util.HashMap anywheresoftware.b4a.BA.htSubs' on a null object reference
    at anywheresoftware.b4a.agraham.threading.Threading.Start(
    at it.davidev.libs.superuser.superuser._checkforroot(
    at it.davidev.tagapplauncher.starter$ResumableSub_checkRoot.resume(
    at it.davidev.tagapplauncher.starter._checkroot(
    at it.davidev.tagapplauncher.starter._service_start(
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(
    at anywheresoftware.b4a.BA.raiseEvent(
    at it.davidev.tagapplauncher.starter.handleStart(
    at it.davidev.tagapplauncher.starter.access$000(
    at it.davidev.tagapplauncher.starter$
    at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(
    at it.davidev.tagapplauncher.starter.onStartCommand(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)

Thanks in advance
Last edited:


Licensed User
i would run checkroot in service_start
Additionally i don´t see ou initialising kvs. Post an example project
Upvote 0


Active Member
Licensed User
i would run checkroot in service_start
Additionally i don´t see ou initialising kvs. Post an example project
Hi Don,
as I wrote, it doesn't work from service_start, it crashes anyway...
KVs is initialized correctly, I removed it from the example as it has nothing to do with the problem. The sub works just fine when called from outside
Upvote 0


Active Member
Licensed User
As you can see from the stack trace this library creates a new thread with the Threading library. It doesn't do it properly so you shouldn't use this library at all.
Yes, the library creates a new thread. But it works fine outside the Starter service...

Well, I'll move that check elsewhere :(
Upvote 0