Hi
I am trying to get this library working, but keep getting the following error when the application is installed on the device.
This is the code I am using as per the example provided with the library.
Anyone can shed any light on this error please.
Thanks
Potman
I am trying to get this library working, but keep getting the following error when the application is installed on the device.
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_activity_resume (java line: 360)
java.lang.IncompatibleClassChangeError: Found class com.google.android.gms.common.api.GoogleApiClient, but interface was expected (declaration of 'com.google.android.gms.common.api.GoogleApiClient' appears in /data/app/uk.co.martinpearman.b4a.fusedlocationproviderexample-1/base.apk)
at uk.co.martinpearman.b4a.fusedlocationprovider.FusedLocationProviderWrapper.Connect(FusedLocationProviderWrapper.java:147)
at uk.co.martinpearman.b4a.fusedlocationproviderexample.main._activity_resume(main.java:360)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at uk.co.martinpearman.b4a.fusedlocationproviderexample.main.afterFirstLayout(main.java:108)
at uk.co.martinpearman.b4a.fusedlocationproviderexample.main.access$000(main.java:17)
at uk.co.martinpearman.b4a.fusedlocationproviderexample.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6823)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1557)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
This is the code I am using as per the example provided with the library.
B4X:
Region Project Attributes
#ApplicationLabel: FusedLocationProvider example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
'#AdditionalRes: C:\Android\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#additionaljar: com.android.support:support-v4
#AdditionalJar: com.google.android.gms:play-services-location
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Private FusedLocationProvider1 As FusedLocationProvider
Private LastLocation As Location
End Sub
Sub Globals
Private LastLocationLabel As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
' ** IMPORTANT see manifest for required entries **
If FirstTime Then
FusedLocationProvider1.Initialize("FusedLocationProvider1")
End If
Activity.LoadLayout("Main")
If LastLocation.IsInitialized Then
UpdateUI
End If
End Sub
Sub Activity_Resume
' attempt to connect to the location services
' after calling Connect we are waiting for either ConnectionFailed or ConnectionSuccess events
FusedLocationProvider1.Connect
End Sub
Sub Activity_Pause (UserClosed As Boolean)
FusedLocationProvider1.Disconnect
End Sub
Sub FusedLocationProvider1_ConnectionFailed(ConnectionResult1 As Int)
Log("FusedLocationProvider1_ConnectionFailed")
' the FusedLocationProvider ConnectionResult object contains the various CoonectionResult constants
Select ConnectionResult1
Case FusedLocationProvider1.ConnectionResult.NETWORK_ERROR
' a network error has occurred, this is likely to be a recoverable error
' so try to connect again
FusedLocationProvider1.Connect
Case Else
' TODO handle other errors
End Select
End Sub
Sub FusedLocationProvider1_ConnectionSuccess
Log("FusedLocationProvider1_ConnectionSuccess")
Dim LocationRequest1 As LocationRequest
LocationRequest1.Initialize
LocationRequest1.SetInterval(1000) ' 1000 milliseconds
LocationRequest1.SetPriority(LocationRequest1.Priority.PRIORITY_HIGH_ACCURACY)
LocationRequest1.SetSmallestDisplacement(1) ' 1 meter
FusedLocationProvider1.RequestLocationUpdates(LocationRequest1)
End Sub
Sub FusedLocationProvider1_ConnectionSuspended(SuspendedCause1 As Int)
Log("FusedLocationProvider1_ConnectionSuspended")
' the FusedLocationProvider SuspendedCause object contains the various SuspendedCause constants
Select SuspendedCause1
Case FusedLocationProvider1.SuspendedCause.CAUSE_NETWORK_LOST
' TODO take action
Case FusedLocationProvider1.SuspendedCause.CAUSE_SERVICE_DISCONNECTED
' TODO take action
End Select
End Sub
Sub FusedLocationProvider1_LocationChanged(Location1 As Location)
Log("FusedLocationProvider1_LocationChanged")
LastLocation=Location1
UpdateUI
End Sub
Sub UpdateUI
LastLocationLabel.Text=DateTime.Time(LastLocation.Time)&" ("&LastLocation.Latitude&", "&LastLocation.Longitude&")"
End Sub
Anyone can shed any light on this error please.
Thanks
Potman