Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location Plugin Crash #381

Closed
rheng001 opened this issue Mar 26, 2018 · 10 comments
Closed

Location Plugin Crash #381

rheng001 opened this issue Mar 26, 2018 · 10 comments
Labels
location-layer-plugin Issues that deal with the location layer module question For any code questions

Comments

@rheng001
Copy link

rheng001 commented Mar 26, 2018

Hi everyone, I have followed the exact instructions from Location Layer Plugin page as well as the code from the demo app and I get an error from the following:

I have two fragments

  • 1 is a Map Fragment with the mapview
  • 1 is a Home fragment

Crashes when I do this:
-From Home fragment -> load Map fragment
-From Map Fragment -> load Home fragment
-From Home fragment -> load Map fragment (CRASH)

03-25 23:39:36.716 29667-29667/campusmate.rmate A/libc: Pure virtual function called. Are you calling virtual methods from a destructor?

03-25 23:39:36.716 29667-29667/campusmate.rmate A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 29667 (ampusmate.rmate)

[ 03-25 23:39:36.719 607: 607 W/ ]
debuggerd: handling request: pid=29667 uid=10453 gid=10453 tid=29667

I have debugged everywhere in my code and I have found out that the culprit is only coming from these two lines

locationPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine); locationPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);

If I comment out these two I can switch back and forth between my fragments just fine without crashing.

GRADLE

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.11.1'
implementation('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.11.1') {
transitive = true
}

Thanks

@cammace
Copy link
Contributor

cammace commented Mar 27, 2018

Make sure you are also including the locationPlugin required lifecycle methods. Sounds like these might be missing.

@cammace cammace added question For any code questions location-layer-plugin Issues that deal with the location layer module labels Mar 27, 2018
@rheng001
Copy link
Author

rheng001 commented Mar 27, 2018

I followed the location plugin instructions and have this in my lifecycle methods as well as other initialization steps.

@OverRide
@SuppressWarnings( {"MissingPermission"})
public void onStart() {
super.onStart();
if (locationEngine != null) {
locationEngine.requestLocationUpdates();
}
if (locationPlugin != null) {
locationPlugin.onStart();
}
mapView.onStart();
}

and

@OverRide
public void onStop() {
super.onStop();

    if (locationEngine != null) {
        locationEngine.removeLocationUpdates();
    }

    if (locationPlugin != null) {
        locationPlugin.onStop();
    }

    mapView.onStop();

}

@cammace
Copy link
Contributor

cammace commented Mar 29, 2018

We just released 0.5.0-beta.1 with a ton of changes, mainly the update to the Map SDK 6.0. While it will require work to make the upgrade, I believe the fix to your issue is found in #307. Can you try this out and confirm this fixes the issue?

@rheng001
Copy link
Author

rheng001 commented Mar 29, 2018

@cammace Okay I will try that. Should my gradle then be

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.0.0-beta.4'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.11.1'
implementation('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.11.1') {
transitive = true
}
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.5.0-beta.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:3.0.0-beta.1'

To use the new updates?

@cammace
Copy link
Contributor

cammace commented Apr 2, 2018

Sorry, I neglected to mention that there's currently not a running nav SDK using the Map SDK 6.0, therefore I'm not sure this is yet testable or you can even compile. in the coming weeks, you'll see an update for all of these SDKs though which will bring compatibility for our map SDK.

@rheng001
Copy link
Author

rheng001 commented Apr 2, 2018

@cammace No problem! Looking forward to the new release.

@rheng001 rheng001 closed this as completed Apr 2, 2018
@viveksaruk
Copy link

I am facing the same issue. Awaiting for the new release.

@samoilovich
Copy link

samoilovich commented May 16, 2018

Hi,
I use "com.mapbox.mapboxsdk:mapbox-android-sdk:6.1.1" and I still have the same issue.
Do you have any updates regarding this issue?

Thanks.

@cammace
Copy link
Contributor

cammace commented May 16, 2018

@samoilovich, this ticket isn't showing code from the latest Location Layer Plugin, can you elaborate a bit more on the issue you are having and how I can reproduce it. Perhaps even opening a new ticket for easier tracking would be best.

@samoilovich
Copy link

@cammace
Sorry for delay. i fixed my issue. It was not the same as here (I understand that now).
The root cause of my crash was a wrong instance of mapbox for locationPlugin.
In two words.
I use fragment. It is attached and detached. And as a result map is recreating all the time but instance of fragment - not. So I used one instance of location plugin and mapbox instance was been recreated every time and when happened onStart() - crash.
My solution is set to null instance of location plugin in the onDestroyView

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
location-layer-plugin Issues that deal with the location layer module question For any code questions
Projects
None yet
Development

No branches or pull requests

4 participants