The question was how to check the version at runtime. However. Please use the search function how to use the phone library or search for "p.sdkversion" to see examples.
If errors occur, we need to see the exception message (via logs). And yes... There are always messages in the logs. Get used to check those messages to know what went wrong. If you get online with your app, you get exactly those messages from Google. So no magic here.
Without starting your app, borrow the phone, go to settings, About the phone, Software info, And check the Android Version. Or somehow ask the user to do it.
After the app is launched, you have the aswer in poast #4. Yo can put that in the starter service. But KMatle is right, if you dont know what is the error or what causes, there is no point on ksnowinf the android version.
Today i got old android version phone, the debug log is:
B4X:
** Service (firebasemessaging) Start **
Error occurred on line: 27 (FirebaseMessaging)
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.tasks.Task com.google.firebase.iid.FirebaseInstanceId.zza(java.lang.String)' on a null object reference
at com.google.firebase.messaging.FirebaseMessaging.subscribeToTopic(Unknown Source)
at anywheresoftware.b4a.objects.FirebaseNotificationsService$FirebaseMessageWrapper.SubscribeToTopic(FirebaseNotificationsService.java:130)
at com.yemenet.aloo.firebasemessaging._subscribetotopics(firebasemessaging.java:210)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:357)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:365)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5912)
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:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)