flutter_mapbox_navigation icon indicating copy to clipboard operation
flutter_mapbox_navigation copied to clipboard

i have a driving app that use flutter_mapbox_navigation as a navigation map but my app crash when the mapbox navigation is called Android 13 and android 14 version

Open adityabaudh7 opened this issue 1 year ago • 9 comments
trafficstars

FATAL EXCEPTION: main E/AndroidRuntime(25984): Process: com.example.driverapp, PID: 25984 E/AndroidRuntime(25984): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.driverapp/com.eopeter.fluttermapboxnavigation.activity.NavigationActivity}: java.lang.SecurityException: com.example.driverapp: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts E/AndroidRuntime(25984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4164) E/AndroidRuntime(25984): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4322) E/AndroidRuntime(25984): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) E/AndroidRuntime(25984): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) E/AndroidRuntime(25984): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) E/AndroidRuntime(25984): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685) E/AndroidRuntime(25984): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(25984): at android.os.Looper.loopOnce(Looper.java:230) E/AndroidRuntime(25984): at android.os.Looper.loop(Looper.java:319) E/AndroidRuntime(25984): at android.app.ActivityThread.main(ActivityThread.java:8893) E/AndroidRuntime(25984): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(25984): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) E/AndroidRuntime(25984): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) E/AndroidRuntime(25984): Caused by: java.lang.SecurityException: com.example.driverapp: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts E/AndroidRuntime(25984): at android.os.Parcel.createExceptionOrNull(Parcel.java:3069) E/AndroidRuntime(25984): at android.os.Parcel.createException(Parcel.java:3053) E/AndroidRuntime(25984): at android.os.Parcel.readException(Parcel.java:3036) E/AndroidRuntime(25984): at android.os.Parcel.readException(Parcel.java:2978) E/AndroidRuntime(25984): at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:6137) E/AndroidRuntime(25984): at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:6137) E/AndroidRuntime(25984): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(25984): at leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:93) E/AndroidRuntime(25984): at java.lang.reflect.Proxy.invoke(Proxy.java:1006) E/AndroidRuntime(25984): at $Proxy3.registerReceiverWithFeature(Unknown Source) E/AndroidRuntime(25984): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1913) E/AndroidRuntime(25984): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1853) E/AndroidRuntime(25984): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1841) 2 E/AndroidRuntime(25984): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:772) E/AndroidRuntime(25984): at com.eopeter.fluttermapboxnavigation.activity.NavigationActivity.onCreate(NavigationActivity.kt:142) E/AndroidRuntime(25984): at android.app.Activity.performCreate(Activity.java:8944) E/AndroidRuntime(25984): at android.app.Activity.performCreate(Activity.java:8913) E/AndroidRuntime(25984): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456) E/AndroidRuntime(25984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4146) E/AndroidRuntime(25984): ... 12 more E/AndroidRuntime(25984): Caused by: android.os.RemoteException: Remote stack trace: E/AndroidRuntime(25984): at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:16580) E/AndroidRuntime(25984): at android.app.IActivityManager$Stub.onTransact$registerReceiverWithFeature$(IActivityManager.java:11530) E/AndroidRuntime(25984): at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2928) E/AndroidRuntime(25984): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3195) E/AndroidRuntime(25984): at android.os.Binder.execTransactInternal(Binder.java:1375) E/AndroidRuntime(25984): I/TextToSpeech(25984): Setting up the connection to TTS engine... I/Mapbox (25984): [nav-native]: No PersistentConfig found at /data/user/0/com.example.driverapp/files/mbx_nav/tiles/navigation/config.json

I/Mapbox (25984): [nav-native]: Async version config for mapbox/driving-traffic resolved with version 2024_04_28-03_00_04 [{"map":{"tileset_version":"2024_04_28-03_00_04"}}] W/Mapbox (25984): [nav-sdk]: [BillingController] [code: TokenValidationFailed, message: Token validation failed for: this-can-be-skip-since-we-set-it-later] I/Process (25984): Sending signal. PID: 25984 SIG: 9 Lost connection to device.

Exited.

adityabaudh7 avatar May 03 '24 05:05 adityabaudh7

Same issue, downgrading the compileSdkVersion to 33 solves the issue. Please fix that as version 33 limits the functionality with other libraries. Thanks

YoavSl avatar May 06 '24 12:05 YoavSl

This is still not working despite changing the SDK version.

wheelie33 avatar Jul 09 '24 13:07 wheelie33

Hello Guys, I found the issue, Issue in registerReceiver b'coz in android 14 there is argument changed in android 14, So we need to change in registerReceiver.

android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/activity/NavigationActivity.kt In this file you need to add the below codes for registerReceiver.

In the import section:

  1.   import androidx.core.content.ContextCompat
    

at registerReceiver replace this registerReceiver code:

  1.  registerReceiver(
       finishBroadcastReceiver,
      IntentFilter(NavigationLauncher.KEY_STOP_NAVIGATION),
      ContextCompat.RECEIVER_NOT_EXPORTED)
    
  2.   registerReceiver(
          addWayPointsBroadcastReceiver,
        IntentFilter(NavigationLauncher.KEY_ADD_WAYPOINTS),
         ContextCompat.RECEIVER_NOT_EXPORTED)
    

I hope it is works for you.

jayu146 avatar Jul 11 '24 12:07 jayu146

When is this fix going to be included in master branch?

Hello Guys, I found the issue, Issue in registerReceiver b'coz in android 14 there is argument changed in android 14, So we need to change in registerReceiver.

android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/activity/NavigationActivity.kt In this file you need to add the below codes for registerReceiver.

In the import section:

  1.   import androidx.core.content.ContextCompat
    

at registerReceiver replace this registerReceiver code:

  1.  registerReceiver(
       finishBroadcastReceiver,
      IntentFilter(NavigationLauncher.KEY_STOP_NAVIGATION),
      ContextCompat.RECEIVER_NOT_EXPORTED)
    
  2.   registerReceiver(
          addWayPointsBroadcastReceiver,
        IntentFilter(NavigationLauncher.KEY_ADD_WAYPOINTS),
         ContextCompat.RECEIVER_NOT_EXPORTED)
    

I hope it is works for you.

henycave avatar Jul 26 '24 12:07 henycave

Hi everyone, it worked, thanks for the support

marciotisouza avatar Aug 20 '24 11:08 marciotisouza

This is the key, i had a lot of problems while cancel/finish the navigation, but modifying the package with this all works like a clock! I don't know why this does not merge into the main branch.

Hello Guys, I found the issue, Issue in registerReceiver b'coz in android 14 there is argument changed in android 14, So we need to change in registerReceiver.

android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/activity/NavigationActivity.kt In this file you need to add the below codes for registerReceiver.

In the import section:

  1.   import androidx.core.content.ContextCompat
    

at registerReceiver replace this registerReceiver code:

  1.  registerReceiver(
       finishBroadcastReceiver,
      IntentFilter(NavigationLauncher.KEY_STOP_NAVIGATION),
      ContextCompat.RECEIVER_NOT_EXPORTED)
    
  2.   registerReceiver(
          addWayPointsBroadcastReceiver,
        IntentFilter(NavigationLauncher.KEY_ADD_WAYPOINTS),
         ContextCompat.RECEIVER_NOT_EXPORTED)
    

I hope it is works for you.

ivan-acosta08 avatar Aug 28 '24 10:08 ivan-acosta08

I'm also getting the "One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts" on startNavigation since I upgraded compileSdkVersion from 33 to 34.

It is a Google Play requirement to target at least API 34 (Android 14), so downgrading back to 33 it's not an option.

I'm also not able to make these changes. The file NavigationActivity.kt doesn't exist in my project. How can I fix this?

Hello Guys, I found the issue, Issue in registerReceiver b'coz in android 14 there is argument changed in android 14, So we need to change in registerReceiver.

android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/activity/NavigationActivity.kt In this file you need to add the below codes for registerReceiver.

In the import section:

  1.   import androidx.core.content.ContextCompat
    

at registerReceiver replace this registerReceiver code:

  1.  registerReceiver(
       finishBroadcastReceiver,
      IntentFilter(NavigationLauncher.KEY_STOP_NAVIGATION),
      ContextCompat.RECEIVER_NOT_EXPORTED)
    
  2.   registerReceiver(
          addWayPointsBroadcastReceiver,
        IntentFilter(NavigationLauncher.KEY_ADD_WAYPOINTS),
         ContextCompat.RECEIVER_NOT_EXPORTED)
    

I hope it is works for you.

ffkarine avatar Aug 28 '24 14:08 ffkarine

I'm also getting the "One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts" on startNavigation since I upgraded compileSdkVersion from 33 to 34.

It is a Google Play requirement to target at least API 34 (Android 14), so downgrading back to 33 it's not an option.

I'm also not able to make these changes. The file NavigationActivity.kt doesn't exist in my project. How can I fix this?

@ffkarine If you are using Windows go to %localappdata%\pub\Cache\hosted\pub.dev\flutter_mapbox_navigation-0.2.2, here is where you can find 'android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/activity/NavigationActivity.kt' and remember trying to not execute pub get and make a backup of the library locally

ivan-acosta08 avatar Aug 28 '24 15:08 ivan-acosta08

Thank you so much for explaining it to me @ivan-acosta08 and thank you @jayu146 for the solution too! Now it's working again!

ffkarine avatar Aug 28 '24 17:08 ffkarine