Closed lucasdk3 closed 1 year ago
also getting this issue when launching example app
Make sure you follow the directions to set your MapBox token On Apr 11, 2023, at 9:41 AM, Nick Wilkins @.***> wrote: also getting this issue when launching example app
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
set it in both the strings.xml and in gradle, even setting the string directly in here this variable doesn't appear to work
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Navigation map</string>
<string name="mapbox_access_token" translatable="false">pk....</string>
<string name="user_location_permission_explanation">This app needs location permissions to show its functionality.</string>
<string name="user_location_permission_not_granted">You didn\'t grant location permissions.</string>
</resources>
navigation_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<com.mapbox.navigation.dropin.NavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:accessToken="pk...">
</com.mapbox.navigation.dropin.NavigationView>
@nick92 Could you solve this problem? I'm currently presenting it too and I can't find the solution. Your help would be very helpful.
This only seems to happen with the embedded view on Android, which various other flutter mapbox navigation projects have said is challenging to implement. I followed the setup instructions here (https://flutterawesome.com/a-repository-to-demonstrate-the-use-of-mapbox-its-maps-and-navigation-sdks-in-a-flutter-application/) and managed to get everything in this repo working, APART from the embedded view.
This repo (https://pub.dev/packages/flutter_mapbox/example) DOES have a working embedded map that works, but the routing doesn't seem to work.
No definitive solutions but hopefully some places where people can go digging to find out why things do and don't work. I'll keep investigating.
Funny enough that's a repo that I manage, it's originally a fork of this repo before they made some changes to how the navigation UI elements are called within Android, both embedded mapping and routing should work on both Android and iOS
This issue is around a new element in which this repo uses over that which is the drop in navigation UI element that is provided by Mapbox, we don't use that in that repo we use the MapView and then add the banners HUD on top of it for the full screen navigastion
The issue is that the drop in UI is complaining about the Mapbox access key not being passed in where it clearly is being provided and even passed in as a string directly
So just a question as to whether this is an issue within this repo or with Mapbox as to why this isn't being picked up
I have solved that.
so this issue should be resolved now?
Yes.
Can you send a PR with the solution?
Hello everyone! I hope this message finds you well. I just wanted to share that I've been working on a new plugin that I think might be helpful for some people. The structure is a bit different than what's currently available, So, it may not be easy to integrate into your code at the moment. If you have any questions or would like to learn more about it, feel free to send me an email and I'll be happy to chat further. Thanks for your time!
Instead of creating a new plugin, why don’t you send a PR to avoid populating pub spec with so many similar plugins that confuses users? I am ok with doing a major version and force pushing a branch that resolves major issues. On Apr 24, 2023, at 8:26 AM, Mostafa Mahmoud @.***> wrote: Hello everyone! I hope this message finds you well. I just wanted to share that I've been working on a new plugin that I think might be helpful for some people. The structure is a bit different than what's currently available, So, it may not be easy to integrate into your code at the moment. If you have any questions or would like to learn more about it, feel free to send me an email and I'll be happy to chat further. Thanks for your time!
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Is there anyway to disable the drop-in ui and get the embedded navigation to work on Android? The embedded navigation works flawlessly on iOS so should be good to get it working on Android.
@nick92 I tried https://pub.dev/packages/flutter_mapbox/example and route building is working on Android and iOS (buggy though, a bunch of NPE) but actually start the navigation itself doesn't seems to work.
Tracing android codes, it looks like we need to use different android Activity
class so in the example project I changed
MainActivity.kt
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
to
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
}
FlutterFragmentActivity
implements ViewModelStoreOwner
which is expected by mapbox's NavigationView
.
Now missing plugin errors when trying to navigate
The following MissingPluginException was thrown while activating platform stream on channel flutter_mapbox_navigation/0/events: MissingPluginException(No implementation found for method listen on channel flutter_mapbox_navigation/0/events)
Is this with or without drop-in Ui?On May 9, 2023, at 8:01 PM, phongkien @.***> wrote: Now missing plugin errors when trying to navigate The following MissingPluginException was thrown while activating platform stream on channel flutter_mapbox_navigation/0/events: MissingPluginException(No implementation found for method listen on channel flutter_mapbox_navigation/0/events)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
With drop-in, the only changes are below: https://github.com/phongkien/flutter_mapbox_navigation/commit/a84109bcd8a49a1431aa65ccfef59f5f8596a124
Looks like there are still a lot of work to do in order for the embedded drop-in ui to work.
e.g. TurnByTurn
class has a bunch of lateinit
members that's never initialized.
The full screen uses the drop in Ui and TurnByTurn class. We can reuse that for the embedded On May 9, 2023, at 10:41 PM, phongkien @.***> wrote: Looks like there are still a lot of work to do in order for the embedded drop-in ui to work. e.g. TurnByTurn class has a bunch of lateinit members that's never initialized.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Finally got it working using drop-in navigation. Probably need some refactoring to share codes between full screen and embedded. Ripped out the old embedded navigation and replaced it with drop-in. Still need to support other features but at least navigation is working. Will send PR later.
Woohoo!! That’s great!!On May 11, 2023, at 3:38 PM, phongkien @.***> wrote: Finally got it working using drop-in navigation. Probably need some refactoring to share codes between full screen and embedded. Ripped out the old embedded navigation and replaced it with drop-in. Still need to support other features but at least navigation is working. Will send PR later.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Amazing! I've just started adding functionality for a pull up bottom tray to hold a list of all waypoints on a route that can be toggled on and off (think of skipping stops in a delivery route). Not easy in native controls... it will be much easier to do with controls on top of embedded!
On Thu, 11 May 2023, 20:38 phongkien, @.***> wrote:
Finally got it working using drop-in navigation. Probably need some refactoring to share codes between full screen and embedded. Ripped out the old embedded navigation and replaced it with drop-in. Still need to support other features but at least navigation is working. Will send PR later.
— Reply to this email directly, view it on GitHub https://github.com/eopeter/flutter_mapbox_navigation/issues/209#issuecomment-1544572381, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN555K3LK6UKHX7DZBIKNDXFU53TANCNFSM6AAAAAAWO376SY . You are receiving this because you commented.Message ID: @.***>
yeah, that's the primary reason why I need embedded version.
In that case I'll keep going, just in case you hit any problems. I've got the android version working fine. The ios bottom tray is in place. I just need to add switches for the waypoints.
On Thu, 11 May 2023, 23:10 phongkien, @.***> wrote:
yeah, that's the primary reason why I need embedded version.
— Reply to this email directly, view it on GitHub https://github.com/eopeter/flutter_mapbox_navigation/issues/209#issuecomment-1544756588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN555PLCZBZJJF5FSAYY33XFVPTXANCNFSM6AAAAAAWO376SY . You are receiving this because you commented.Message ID: @.***>
I am assuming the additional widgets you are adding is on the flutter side; not platform side. That should not be part of the plugin thoughOn May 11, 2023, at 6:25 PM, Neil Dunlop @.***> wrote: In that case I'll keep going, just in case you hit any problems. I've got the android version working fine. The ios bottom tray is in place. I just need to add switches for the waypoints.
On Thu, 11 May 2023, 23:10 phongkien, @.***> wrote:
yeah, that's the primary reason why I need embedded version.
— Reply to this email directly, view it on GitHub https://github.com/eopeter/flutter_mapbox_navigation/issues/209#issuecomment-1544756588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN555PLCZBZJJF5FSAYY33XFVPTXANCNFSM6AAAAAAWO376SY . You are receiving this because you commented.Message ID: @.***>
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Yes you should implement any additional widgets on the flutter side. New or latest codes should emit routes information to allow you to customize the UI.
This is what I have on the flutter side. Just a sample, I have other stuff but I used the information from route_built
response. It emit infos from https://docs.mapbox.com/api/navigation/directions/#route-object
example
void handleRouteEvent(RouteEvent event) {
if (event.eventType == MapBoxEvent.route_built) {
_decodeRouteBuiltEventData(event.data);
...
}
}
void _decodeRouteBuiltEventData(dynamic data) {
if (data is String && data.isNotEmpty) {
try {
final ls = jsonDecode(data);
if (ls is List && ls.isNotEmpty) {
//see https://docs.mapbox.com/api/navigation/directions/#route-object
//duration in ms
final duration = ls.first['duration'];
//distance in meter
final distance = ls.first['distance'];
if (duration is double) {
durationRemaining = duration;
}
if (distance is double) {
distanceRemaining = distance;
}
//legs is an array, usually 1
//each leg can have steps (for this cause, should have steps)
//see https://docs.mapbox.com/api/navigation/directions/#route-leg-object
// final legs = ls.first['legs'];
// print(legs);
} else if (ls is String) {
_decodeRouteBuiltEventData(ls);
}
} catch (e) {
Logging.instance.log('Failed to decode RouteEvent data');
}
}
}
The widgets were being added on the platform side. It's absolutely not the right thing to do for a generically useful plugin, but it's what I needed for a fixed deadline deliverable. The plan was never to merge this functionality back into the main project. It only exists on a branch of my fork because there would be no way to control or customise the contents of the panel (without lots of painful work). My plan was to prove the concept and then look at getting embedded working once I had more time.
On Thu, 11 May 2023 at 23:29, Emmanuel Oche @.***> wrote:
I am assuming the additional widgets you are adding is on the flutter side; not platform side. That should not be part of the plugin thoughOn May 11, 2023, at 6:25 PM, Neil Dunlop @.***> wrote: In that case I'll keep going, just in case you hit any problems. I've got the android version working fine. The ios bottom tray is in place. I just need to add switches for the waypoints.
On Thu, 11 May 2023, 23:10 phongkien, @.***> wrote:
yeah, that's the primary reason why I need embedded version.
— Reply to this email directly, view it on GitHub < https://github.com/eopeter/flutter_mapbox_navigation/issues/209#issuecomment-1544756588 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAN555PLCZBZJJF5FSAYY33XFVPTXANCNFSM6AAAAAAWO376SY
. You are receiving this because you commented.Message ID: @.***>
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/eopeter/flutter_mapbox_navigation/issues/209#issuecomment-1544775297, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN555PJLVK43BDXHUJAJTTXFVR6LANCNFSM6AAAAAAWO376SY . You are receiving this because you commented.Message ID: @.***>
Understood! Embedded is now working for me but some painful changes are needed, see PR for changes: https://github.com/eopeter/flutter_mapbox_navigation/pull/225/files
However, there are still things need to be implemented, but the main functionality (navigation) is working.
Instead of creating a new plugin, why don’t you send a PR to avoid populating pub spec with so many similar plugins that confuses users? I am ok with doing a major version and force pushing a branch that resolves major issues. On Apr 24, 2023, at 8:26 AM, Mostafa Mahmoud @.***> wrote: Hello everyone! I hope this message finds you well. I just wanted to share that I've been working on a new plugin that I think might be helpful for some people. The structure is a bit different than what's currently available, So, it may not be easy to integrate into your code at the moment. If you have any questions or would like to learn more about it, feel free to send me an email and I'll be happy to chat further. Thanks for your time!
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Hi everyone,
I apologize for my recent absence as I have been quite busy. I appreciate your understanding and patience.
I acknowledge and agree with your perspective. Initially, I had the impression that support for the package had been discontinued, which prompted me to undertake a separate project. However, we should strive to keep the current plugin organized for future contributions. Unfortunately, I don't currently have the capacity to rework adjustments to the plugin's features in order to align it safely with your plugin structure.
Nevertheless, I'm thrilled that a dedicated contributor has invested their time in fixing the issue. Great work!.
If any assistance is required with my solution, I would be more than happy to share it with you. The solution I propose does not require a drop-in approach; instead, it builds upon the existing dependencies.
Best regards,
set it in both the strings.xml and in gradle, even setting the string directly in here this variable doesn't appear to work
strings.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Navigation map</string> <string name="mapbox_access_token" translatable="false">pk....</string> <string name="user_location_permission_explanation">This app needs location permissions to show its functionality.</string> <string name="user_location_permission_not_granted">You didn\'t grant location permissions.</string> </resources>
navigation_activity.xml
<?xml version="1.0" encoding="utf-8"?> <com.mapbox.navigation.dropin.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="match_parent" app:accessToken="pk..."> </com.mapbox.navigation.dropin.NavigationView>
set it in both the strings.xml and in gradle, even setting the string directly in here this variable doesn't appear to work
strings.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Navigation map</string> <string name="mapbox_access_token" translatable="false">pk....</string> <string name="user_location_permission_explanation">This app needs location permissions to show its functionality.</string> <string name="user_location_permission_not_granted">You didn\'t grant location permissions.</string> </resources>
navigation_activity.xml
<?xml version="1.0" encoding="utf-8"?> <com.mapbox.navigation.dropin.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="match_parent" app:accessToken="pk..."> </com.mapbox.navigation.dropin.NavigationView>
Hi @nick92 can you please tell me where to create this navigation_activity.xml file?
You do not need to create navigation_activity.xml. Please read the ReadMe to see how to properly set your token.
On Thu, May 18, 2023 at 8:08 AM Muhammad Usama Kabir < @.***> wrote:
set it in both the strings.xml and in gradle, even setting the string directly in here this variable doesn't appear to work
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
Navigation map pk.... This app needs location permissions to show its functionality. You didn\'t grant location permissions. navigation_activity.xml
<?xml version="1.0" encoding="utf-8"?> <com.mapbox.navigation.dropin.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="match_parent" app:accessToken="pk..."> </com.mapbox.navigation.dropin.NavigationView>
set it in both the strings.xml and in gradle, even setting the string directly in here this variable doesn't appear to work
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
Navigation map pk.... This app needs location permissions to show its functionality. You didn\'t grant location permissions. navigation_activity.xml
<?xml version="1.0" encoding="utf-8"?> <com.mapbox.navigation.dropin.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="match_parent" app:accessToken="pk..."> </com.mapbox.navigation.dropin.NavigationView>
Hi nick92 can you please tell me where to create this navigation_activity.xml file?
— Reply to this email directly, view it on GitHub https://github.com/eopeter/flutter_mapbox_navigation/issues/209#issuecomment-1552960165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPLOM4FLENAJ56ABBHPTQLXGYGLJANCNFSM6AAAAAAWO376SY . You are receiving this because you commented.Message ID: @.***>
-- Sincerely Emmanuel Oche
This issue is resolved
android.view.InflateException: Binary XML file line #8 in com.eopeter.flutter_mapbox_navigation_example:layout/navigation_activity: Binary XML file line #8 in com.eopeter.flutter_mapbox_navigation_example:layout/navigation_activity: Error inflating class com.mapbox.navigation.dropin.NavigationView E/MethodChannel#flutter/platform_views(27734): Caused by: android.view.InflateException: Binary XML file line #8 in com.eopeter.flutter_mapbox_navigation_example:layout/navigation_activity: Error inflating class com.mapbox.navigation.dropin.NavigationView E/MethodChannel#flutter/platform_views(27734): Caused by: java.lang.reflect.InvocationTargetException E/MethodChannel#flutter/platform_views(27734): at java.lang.reflect.Constructor.newInstance0(Native Method) E/MethodChannel#flutter/platform_views(27734): at java.lang.reflect.Constructor.newInstance(Constructor.java:343) E/MethodChannel#flutter/platform_views(27734): at android.view.LayoutInflater.createView(LayoutInflater.java:883) E/MethodChannel#flutter/platform_views(27734): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1035) E/MethodChannel#flutter/platform_views(27734): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:990) E/MethodChannel#flutter/platform_views(27734): at android.view.LayoutInflater.inflate(LayoutInflater.java:688) E/MethodChannel#flutter/platform_views(27734): at android.view.LayoutInflater.inflate(LayoutInflater.java:548) E/MethodChannel#flutter/platform_views(27734): at eopeter.flutter_mapbox_navigation.databinding.NavigationActivityBinding.inflate(NavigationActivityBinding.java:42) E/MethodChannel#flutter/platform_views(27734): at eopeter.flutter_mapbox_navigation.databinding.NavigationActivityBinding.inflate(NavigationActivityBinding.java:36) E/MethodChannel#flutter/platform_views(27734): at com.eopeter.flutter_mapbox_navigation.factory.EmbeddedNavigationViewFactory.create(EmbeddedNavigationViewFactory.kt:25) E/MethodChannel#flutter/platform_views(27734): at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:503) E/MethodChannel#flutter/platform_views(27734): at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:191) E/MethodChannel#flutter/platform_views(27734): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:128) E/MethodChannel#flutter/platform_views(27734): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55) E/MethodChannel#flutter/platform_views(27734): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)