I have a fairly simple application that in theory should use Android Java API to get the location ( inspired by this answer ):
package main
import (
"Java/android/content/Context"
"Java/android/location/LocationManager"
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)
func GetLocation() string {
locationManager := ctx.GetSystemService(Context.LOCATION_SERVICE)
location := locationManager.GetLastKnownLocation(LocationManager.GPS_PROVIDER)
lat := location.GetLatitude()
lng := location.GetLongitude()
return fmt.Sprintf("%f:%f", lat, lng)
}
func main() {
a := app.New()
w := a.NewWindow("Location")
loc := widget.NewLabel("Location defined " + GetLocation())
w.SetContent(widget.NewVBox(
loc,
))
w.ShowAndRun()
}
Yet I can't get it working with the build command as fyne package -os android -appID com.user.fynedemo -icon icon.png
- it fails with the error:
fyne package -os android -appID com.jdevelop.fynedemo -icon 1x1-00000000.png
go build -buildmode=c-shared -o /tmp/gomobile-work-028676736/lib/armeabi-v7a/libfynedemo.so fynedemo failed: exit status 1
a.go:3:8: package Java/android/content/Context is not in GOROOT (/usr/lib/go/src/Java/android/content/Context)
a.go:4:8: package Java/android/location/LocationManager is not in GOROOT (/usr/lib/go/src/Java/android/location/LocationManager)
To me it looks like Go->Java bindings are not generated, so I wonder what would be the first step for getting this working?