Day 23 Re-Googling
MapBox is back in its box and Google Maps are back in the app
I was really hoping to be able to get rid of the dependency on Google Maps and was looking forward to using all the additional features provided by the MapBox library but I just couldn’t get the application stable once I switch to MapBox.
The first couple of crashes were just down to me not understanding the requirements for the MapBox widget. The MapView needs to be hooked into the life-cycle of the Activity or Fragment it’s hosted in so it can do house keeping during device rotations and view inflation. This required forwarding calls to onCreate()
, onStart()
, onPause()
, onResume()
, onDestroy()
and onSaveInstanceState()
to the MapBox map widget.
This solved most of the crashes but the application would randomly close, with no errors/exceptions logged to the debug log. On top of this using MapBox forced me to include a library that Google have deprecated and added 8MB to the size of the application APK (the debug build was 12MB with MapBox and is 4MB with Google Maps).
As noted in my previous post, this also meant that the app now exceeded the upper limit for symbol references in a single DEX file so I had to use the MultiDex library just to get it to compile.
So, unfortunately, MapBox is out for the moment but I’ll be keeping an eye on the library and hopefully there are some improvements made when/if they do a release to replace the use of the now deprecated LocalBroadcastManager
component.
So, I’ve switched back to Google Maps, but took the time to replace the MapFragments I was using with MapView (it turns out that MapBox is very closely modeled on the Google Maps API and the Google MapView also needs to be hooked into the host Activity/Fragment life-cycle in the same way … but doesn’t cause random crashes).
I was away for most of the day today so didn’t get much more than switching back to Google Maps done. I did however write some support code for using the Google MapViews directly and replaced the tabbed UI in my RouteDetailFragment
I decided to put a preview of the map with route (The route will be plotted soon™️) on the top and made the bottom part of the fragment with the stats scroll-able. The plan is to have an option to make the preview map full screen (probably via double tap or an overlaid button)
But after I made this changes I remembered that I would like this Fragment to work in landscape mode too, so I will probably still need a tabbed UI in landscape … but that’s a job for another day.
Oh, and while I was away today, I remembered to enable tracking so got some testing done and collected over 100Km of GPS fixes
Shecks