Android Question Fused Location Provider - Backwards compatability

Derek Johnson

Active Member
Licensed User
Longtime User
I have an App that uses the FLP library Version 1.31. In the Manifest it <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="31"/>.

When installed on devices with SDK 27 and SDK31 the FLP has no issues and FLP Connections work OK.

I then tried the same code on a device running SDK 22 with Android 5.1. In this case the FLP Connections fail with the code 2 "SERVICE VERSION UPDATE REQUIRED"

This is the full manifest file :

Manifest File:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="31"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
  
AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)
  
'RemovePermission(android.permission.WRITE_EXTERNAL_STORAGE)
'
'AddManifestText(<uses-permission
'    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
'    android:maxSdkVersion="18"/>
')
  
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

'End of default text.
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:theme, "@style/MyAppTheme")

SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
CreateResource(mipmap-anydpi-v26, ic_launcher.xml,
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/background"/>
<foreground android:drawable="@mipmap/foreground"/>
</adaptive-icon>
)

AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_COARSE_LOCATION) 'May not be needed

AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" 
     />)

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="colorAccent">#0098EE</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>
</resources>
)

Is there a change that I can make to the manifest file to overcome this issue?
 
Last edited:

TILogistic

Expert
Licensed User
Longtime User
test
remember to jetifier in the toolbar menu
B4X:
    #AdditionalJar: com.android.support:support-v4
    #AdditionalJar: com.google.android.gms:play-services-location

B4X:
'************ FusedLocationProvider ************

'Check found GPS hardware
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)

AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
   
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
 
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
test
remember to jetifier in the toolbar menu
B4X:
    #AdditionalJar: com.android.support:support-v4
    #AdditionalJar: com.google.android.gms:play-services-location

B4X:
'************ FusedLocationProvider ************

'Check found GPS hardware
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)

AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
   
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
I'll try this and see if it helps. Thanks. Derek
 
Upvote 0
Top