0

我正在尝试使用 Mapbox SDK for Android 获取用户的当前位置。在查看了教程和其他所有可用的内容后,我得出结论,显示的所有技术都包括不推荐使用的方法。

我尝试使用以下技术,因为可能是我唯一的镜头,但我遇到了一个我无法解决的错误:error: cannot access LocationListener class file for com.google.android.gms.location.LocationListener not found.

这是我产生错误的代码的一部分:

@Override
protected void onCreate(Bundle savedInstanceState) {
    context = this;
    super.onCreate(savedInstanceState);
    Mapbox.getInstance(this, API_KEY);

    setContentView(R.layout.activity_map_view_test);


    locationEngine = GoogleLocationEngine.getLocationEngine(context);

    myLocation = locationEngine.getLastLocation();


    mapView = (MapView) findViewById(R.id.mapView);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(final MapboxMap mapboxMap) {
            mapboxMap.addMarker(new MarkerOptions()
                    .position(new LatLng(myLocation.getLatitude(),myLocation.getLongitude()))
                    .title("My Location")
                    .snippet("Illinois")
            );

            mapboxMap.setLatLng(mapboxMap.getMarkers().get(0).getPosition());
        }
    });
}

有没有人有一些好主意?任何帮助都将不胜感激。

此致,

迪米塔尔·格奥尔基耶夫

4

2 回答 2

0

请检查您Proguard Rules是否启用shrink resourcesGradle

于 2018-07-03T11:25:39.047 回答
-1

你真的需要使用谷歌LocationEngine吗?我使用LocationEngine了 SDK 提供的MapBox工具,结果非常好用。您可以尝试导入:

com.mapbox.android.core.location.LocationEngine;
于 2018-07-03T10:22:46.613 回答