Android Question Check android version before app initialize?

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Hi, How to Check android version before app initialize and crash in old android versions?
 

npsonic

Active Member
Licensed User
Check minSdkVersion and targetSdkVersion from manifest.

Project > Manifest Editor
Row 5: <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
It crashes with which errormessage???
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
- NO NEED to write everything in bold!

Connect your device with usb and usb-debugging enabled and post the log. Maybe the unfiltered log from logcat.

In fact there IS a log. Without positing it it is hard to give any advices.

I don´t plan to give any more answer here
 
Upvote 0

npsonic

Active Member
Licensed User
I don't understand why you can't just modify minSdkVersion.
If your app doesn't work with the older sdks you should set it correctly from manifest.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
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.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
I want to check before app started

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.
 
Last edited:
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
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)
 
Upvote 0

npsonic

Active Member
Licensed User
This is what i need .. How to do check version compatibility in manifest?
Check my first answer. You have to set higher min sdk value. There is no other way.
 
Upvote 0
Top