Android Question Android 14 App not launching

ilan

Expert
Licensed User
Longtime User
Hello,

i got some emails from users complaining that my apps won't start on there phones. after some checks i can confirm that my app does not ALWAYS launch the same on Android 14.
in the logs i can see that the Starter Service is started but app not.
the problem is that it is not always happening. after install the first start always works fine but then closing the app completely (no just sending to background) and then start again i only see a white screen.

if you want to reproduce the issue just run an Android 14 Emulator or physical device and install the app in release mode. Then perform a complete close and start again. repeat this process several times and you should get into a white screen.
Logs will show that the starter service has started but the app not.

there is some discussion about it here: https://www.b4x.com/android/forum/t...ui-6-0-samsung-android-14.157493/#post-967625

i have the feeling that google again changed something with services and that the starter service not always starts the app.

any idea how to fix it?
 

ilan

Expert
Licensed User
Longtime User
i also noticed that when i close the app and remove it from the stack the starter service is created. when i again open the app the starter service is started and not created and in this scenario the app won't start.
to start the app the service need to be created then it will start the app.
see video:

 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
it would help very much if you provide a small example project showing the issue.

Completely hiding all code, manifest ect is of no help at all
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
it would help very much if you provide a small example project showing the issue.

Completely hiding all code, manifest ect is of no help at all
Hi dear @DonManfred.
Look at this thread, the problem is also found with the basic app

in particular
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
it would help very much if you provide a small example project showing the issue.

Completely hiding all code, manifest ect is of no help at all
actually it will do it with the default b4a app.
open b4a and create a new project (default)

install android 14 on the emulator and run the app in release mode.
then close app -> open -> close -> open and you will see it that it will start without loading layout. and in logs the service starter is started but not created, it is created when you remove the app from the app stack as shown in the video.

it is effecting any app that will run on android 14 even without using any special libraries.
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
here is an example with the default b4a app

Have you tried stopping the Starter service?
I have long been in the habit of stopping the service in every application so that there is no problem when restarting.

I know that this is not recommended, but I get along very well with it.

B4X:
Sub Activity_Pause (UserClosed As Boolean)
'    Log("Activity_Pause UserClosed=" & UserClosed)
    
    If UserClosed Then               
        'Service beenden
        CallSub(Starter, "Service_Stop")
        
        ExitApplication
    End If
End Sub
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Have you tried stopping the Starter service?
I have long been in the habit of stopping the service in every application so that there is no problem when restarting.

I know that this is not recommended, but I get along very well with it.

B4X:
Sub Activity_Pause (UserClosed As Boolean)
'    Log("Activity_Pause UserClosed=" & UserClosed)
  
    If UserClosed Then             
        'Service beenden
        CallSub(Starter, "Service_Stop")
      
        ExitApplication
    End If
End Sub
But if you return to the app you will need to load everything again.
This is not the way i would like to solve the issue. The app should be able to go to background and allow a quick return but when the app is removed from the background tasks it should work when you open it again. And on android 14 there seems to be an issue with the starter service but i am not sure
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Removing the starter service will probably solve it.
I'm investigating this issue.

Note that with B4XPages (and receivers) the starter service is less important.
thanks for your feedback erel,
since it is an old project i am using the starter service to load many stuff and store them there.
it is not a b4xpages app it is a b4a only app.
removing the starter service will cause other issues i guess like getting variables from activity to another. with the starter service all public variables are stored there and it is safer to use them

should i change the starter service with a receiver ?
what do you recommend to do?

thank you
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
This is not true, because the starter is created again and loads everything again.
as i said it will started again and load everything again and that takes time.
if you use ExitApplication the app goes also from background and you will need to make a full app start but if you use activity.finish or just go to main screen on your android device the app and all UI is still available and the return to the app is much much quicker.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
should i change the starter service with a receiver ?
A receiver will not help here.

it is not a b4xpages app it is a b4a only app.
(It doesn't matter. All new projects should be based on B4XPages.)

Add this code to the main module:
B4X:
#If JAVA
public void _onCreate() {
   BA.Log("_onCreate");
}
#End If

Post the logs when the white screen happens.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
A receiver will not help here.


(It doesn't matter. All new projects should be based on B4XPages.)

Add this code to the main module:
B4X:
#If JAVA
public void _onCreate() {
   BA.Log("_onCreate");
}
#End If

Post the logs when the white screen happens.


ok, i did it with the default b4a app and when the ide first time install the app on the emulator running android 14 i get the whole app start cycle when i close the app -> remove from background i get the Service (starter) Start but not create. it is created on the second you remove it from the background task.

1701165167987.png
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
stopping the service on activity pause seems to solve the issue.
is it ok to call this code erel?

B4X:
Sub Activity_Pause (UserClosed As Boolean)
    If Not(UserClosed) Then StopService(Starter)
End Sub



EDIT: it fixes the behavior and it is also a very simple fix, the question is, is it safe? i made some test and the variables are still available even if i close the app using back key or home button and then return to the app
 
Upvote 0
Top