Android Question [SOLVED] GpsStatus APIs not supported, please use GnssStatus APIs instead

yfleury

Active Member
Licensed User
Longtime User
On my tablet, my app run well. I install it from usb (B4A)

I run my app for 2-3 month now and google map run well.
last night I submit my app on google play for my tester team.
On my phone, I install a newer version from my web site via an autoUpdate in app.
and today, I have this error
B4X:
starter_startgps (java line: 213)
java.lang.UnsupportedOperationException: GpsStatus APIs not supported, please use GnssStatus APIs instead
    at android.location.LocationManager.addGpsStatusListener(LocationManager.java:1998)
    at anywheresoftware.b4a.gps.GPS.Start(GPS.java:103)
....
....

When installing, a warning from installer, from google protect.

I uninstall it and connect my phone to usb and install it with B4A in release mode.
All installation was in release mode.
 
Last edited:
Solution
Ok I find what going wrong.
Before I have this error, my app have targetSdkVersion="30"
I change it to targetSdkVersion="31" then the error on post 1 appear
So, I set targetSdkVersion="30" and my app run well.
Then I set again to targetSdkVersion="31" and comment this sub
B4X:
'Sub GPS_GpsStatus (Satellites As List)
''    CallSub2(Tous_Les_Plans, "GpsStatus", Satellites)
'End Sub
I don't use this sub before anyway. And my app run well now.

In futur, I know I will need to use GNSS library

Thanks guy, you make my day.

agraham

Expert
Licensed User
Longtime User
 
Upvote 1

yfleury

Active Member
Licensed User
Longtime User
Why this change from gps to gnss?
It working well before this error
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
You must have set your target SDK to 31. GpsStatus class was deprecated in API level 24 and I think they must now be enforcing the deprecation.

You can use the GNSS libary above but make sure that you do not have a GpsStatus event Sub in your code as its presence will cause this error. Test this with the demo in the GNSS library archive by removing Sub GNSS_GpsStatus near the bottom of Starter.
 
Last edited:
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Ok I find what going wrong.
Before I have this error, my app have targetSdkVersion="30"
I change it to targetSdkVersion="31" then the error on post 1 appear
So, I set targetSdkVersion="30" and my app run well.
Then I set again to targetSdkVersion="31" and comment this sub
B4X:
'Sub GPS_GpsStatus (Satellites As List)
''    CallSub2(Tous_Les_Plans, "GpsStatus", Satellites)
'End Sub
I don't use this sub before anyway. And my app run well now.

In futur, I know I will need to use GNSS library

Thanks guy, you make my day.
 
Upvote 1
Solution
Top