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

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 #358

Open
adityabaudh7 opened this issue May 3, 2024 · 9 comments

Comments

@adityabaudh7
Copy link

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 adityabaudh7 changed the title When integrating flutter_mapbox into your Android app, it crashes on versions 13 and 14. 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 May 3, 2024
@YoavSl
Copy link

YoavSl commented May 6, 2024

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

@wheelie33
Copy link

This is still not working despite changing the SDK version.

@jayu146
Copy link

jayu146 commented Jul 11, 2024

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
Copy link

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.

@marciotisouza
Copy link

Hi everyone, it worked, thanks for the support

@ivan-acosta08
Copy link

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.

@ffkarine
Copy link

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.

@ivan-acosta08
Copy link

ivan-acosta08 commented Aug 28, 2024

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

@ffkarine
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants