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

Map is Not Showing in Android. #114

Open
NidheeshVgopal opened this issue May 24, 2023 · 24 comments
Open

Map is Not Showing in Android. #114

NidheeshVgopal opened this issue May 24, 2023 · 24 comments

Comments

@NidheeshVgopal
Copy link

React-Native Version: 0.71.4
"@homee/react-native-mapbox-navigation": "^1.1.0",
"@rnmapbox/maps": "^10.0.6".
In my project, there is a requirement to use map and turn-by-turn navigation together.
After some fixes, ios worked fine.
In android side, fixed some issues and finally got issue for

Duplicate class com.mapbox.android.core.location.LocationEngine found in modules jetified-common-23.5.0-runtime (com.mapbox.common:common:23.5.0) and jetified-mapbox-android-core-5.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:5.0.0)
Duplicate class com.mapbox.android.core.location.LocationEngineCallback found in modules jetified-common-23.5.0-runtime (com.mapbox.common:common:23.5.0) and jetified-mapbox-android-core-5.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:5.0.0)
Duplicate class com.mapbox.android.core.location.LocationEngineProvider found in modules jetified-common-23.5.0-runtime (com.mapbox.common:common:23.5.0) and jetified-mapbox-android-core-5.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:5.0.0)
Duplicate class com.mapbox.android.core.location.LocationEngineRequest found in modules jetified-common-23.5.0-runtime (com.mapbox.common:common:23.5.0) and jetified-mapbox-android-core-5.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:5.0.0)
Duplicate class com.mapbox.android.core.location.LocationEngineRequest$1 found in modules jetified-common-23.5.0-runtime (com.mapbox.common:common:23.5.0) and jetified-mapbox-android-core-5.0.0-runtime (com.mapbox.mapboxsdk:mapbox-android-core:5.0.0).

This issue was fixed by changing ode_modules/@homee/react-native
-mapbox-navigation/android/build.gradle'

implementation ('com.mapbox.navigation:core:1.5.0',{
exclude group: "com.mapbox.mapboxsdk", module: "mapbox-android-core"
})
implementation ('com.mapbox.navigation:ui:1.5.0',{
exclude group: "com.mapbox.mapboxsdk", module: "mapbox-android-core"
})
.Then the duplicate issue solved.

But after this when we took the MapboxNavigation in screen, the map is not showing. Even the buttons are not working.
IMG_0040
Is there any solution for this?

@Youssef-Durgham
Copy link

same problem please if you find a solve told me and I will do the same.

@mckeny3
Copy link

mckeny3 commented May 24, 2023

Use dropin ui from mapbox...then use native view manager to display it

@Youssef-Durgham
Copy link

Use dropin ui from mapbox...then use native view manager to display it

sorry for the asking but can you provide me a clear answer and I will be Grateful for you

@Youssef-Durgham
Copy link

Screenshot 2023-05-24 at 11 59 14 PM

and when I return from the map screen to the Home Screen I got this error

@Youssef-Durgham
Copy link

Youssef-Durgham commented May 24, 2023

this is my example code
https://github.com/Youssef-Durgham/alnajaf-taxi-app-zaid-master-new
I don't know how to do it
it take from me 48h and didn't fixed the mapbox code is inside screen folder in CaptainInfoScreen.js

@NidheeshVgopal
Copy link
Author

Hi,
My above issue got fixed when give the meta value inside Application tag of AndroidManifest.xml.
But after this, app is getting crash on launch. This is the error on logcat :

E/AndroidRuntime: FATAL EXCEPTION: MapboxTelemetryExecutor
Process: com.my_project, PID: 4855
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/my_project/android/core/FileUtils;

another issue is ::=>

E/Mbgl-Mapbox: Error occurred while initializing telemetry
java.lang.IllegalArgumentException: com.my_project: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:401)

@Youssef-Durgham
Copy link

Can you see my manifest file where I can move the meta value please ?
And I will see if it works or not and I will try to find solution for it and share the solution if I found it.
Here is the file
https://github.com/Youssef-Durgham/alnajaf-taxi-app-zaid-master-new/blob/master/android/app/src/main/AndroidManifest.xml

@Youssef-Durgham
Copy link

I think it most be outside activity i will try now

@NidheeshVgopal
Copy link
Author

The crash issue was solved. But still getting the blank map on Android.

@Youssef-Durgham
Copy link

I found the solution can you share to me the way you add the <meta-data in the AndroidManifest.xml

@NidheeshVgopal
Copy link
Author

NidheeshVgopal commented May 25, 2023

"





 <meta-data android:name="MAPBOX_DOWNLOADS_TOKEN"
android:value="mapbox_secret_token" />
</application>

inside , after "

@Youssef-Durgham
Copy link

Yeah you should do it like that
<meta-data android:name="MAPBOX_ACCESS_TOKEN" android:value="here add your public token not the private token" />
copy and paste it and told me what you get

@Youssef-Durgham
Copy link

Add to it the public token and the android:name should be MAPBOX_ACCESS_TOKEN

@NidheeshVgopal
Copy link
Author

Now app crashes 2-3 sec after launch.

@Youssef-Durgham
Copy link

Screenshot 2023-05-25 at 8 36 06 AM it works with me with this way but with a blue map with the Mapbox logo but it not show the directions try to change the build.gradle for this library inside module be copy and past all of this instead of the old `

def DEFAULT_COMPILE_SDK_VERSION = 33
def DEFAULT_BUILD_TOOLS_VERSION = '31.0.0'
def DEFAULT_MIN_SDK_VERSION = 24
def DEFAULT_TARGET_SDK_VERSION = 33

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'

buildscript {
ext.kotlin_version = '1.6.20'
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
if (project == rootProject) {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}

repositories {
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'

android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

repositories {
// ref: https://www.baeldung.com/maven-local-repository
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
}
google()
jcenter()
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.mapbox.navigation:core:1.5.0'
implementation 'com.mapbox.navigation:ui:1.5.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

def configureReactNativePom(def pom) {
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)

pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.homee.mapboxnavigation"
description packageJson.description
url packageJson.repository.baseUrl

licenses {
    license {
        name packageJson.license
        url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
        distribution 'repo'
    }
}

}
}

afterEvaluate { project ->
android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()

task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
    from javaCompileTask.destinationDir
}

}
}`

@NidheeshVgopal
Copy link
Author

Screenshot 2023-05-25 at 8 36 06 AM it works with me with this way but with a blue map with the Mapbox logo but it not show the directions try to change the build.gradle for this library inside module be copy and past all of this instead of the old `
def DEFAULT_COMPILE_SDK_VERSION = 33 def DEFAULT_BUILD_TOOLS_VERSION = '31.0.0' def DEFAULT_MIN_SDK_VERSION = 24 def DEFAULT_TARGET_SDK_VERSION = 33

def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback }

apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'maven-publish'

buildscript { ext.kotlin_version = '1.6.20' // The Android Gradle plugin is only required when opening the android folder stand-alone. // This avoids unnecessary downloads and potential conflicts when the library is included as a // module dependency in an application project. // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies if (project == rootProject) { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' } }

repositories { mavenCentral() }

dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }

apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'maven-publish'

android { compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) defaultConfig { minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) versionCode 1 versionName "1.0" } lintOptions { abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } }

repositories { // ref: https://www.baeldung.com/maven-local-repository mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { // Android JSC is installed from npm url "$rootDir/../node_modules/jsc-android/dist" } google() jcenter() }

dependencies { //noinspection GradleDynamicVersion implementation 'com.facebook.react:react-native:+' // From node_modules implementation 'com.mapbox.navigation:core:1.5.0' implementation 'com.mapbox.navigation:ui:1.5.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }

def configureReactNativePom(def pom) { def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)

pom.project { name packageJson.title artifactId packageJson.name version = packageJson.version group = "com.homee.mapboxnavigation" description packageJson.description url packageJson.repository.baseUrl

licenses {
    license {
        name packageJson.license
        url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
        distribution 'repo'
    }
}

} }

afterEvaluate { project -> android.libraryVariants.all { variant -> def name = variant.name.capitalize() def javaCompileTask = variant.javaCompileProvider.get()

task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
    from javaCompileTask.destinationDir
}

} }`

when I added this I got the Duplicate class com.mapbox.android.core.location.... error. How did u fixed this. i was fixed this issue, by changing the implements in the same file? is there any other option?

@Youssef-Durgham
Copy link

In the build.gradle in the app level add this below inside dependencies

implementation "com.mapbox.mapboxsdk:mapbox-android-core:5.0.0" 
implementation('com.mapbox.mapboxsdk:mapbox-android-core:5.0.0') {
        exclude group: 'com.mapbox.common', module: 'common'
}

and if you have an old implementation for mapbox delete them

@Youssef-Durgham
Copy link

And told me will you get a blue screen like mine with the mapbox logo or it will show the directions

@NidheeshVgopal
Copy link
Author

NidheeshVgopal commented May 25, 2023

In the build.gradle in the app level add this below inside dependencies

implementation "com.mapbox.mapboxsdk:mapbox-android-core:5.0.0" 
implementation('com.mapbox.mapboxsdk:mapbox-android-core:5.0.0') {
        exclude group: 'com.mapbox.common', module: 'common'
}

and if you have an old implementation for mapbox delete them

Duplicate class com.mapbox.android.core.location.LocationEngine issue is not got resolved.
I have added the above inside my project/android/app/build.gradle inside depenedencies

@Youssef-Durgham
Copy link

I fix it by this way I don’t know try to search for it

@mckeny3
Copy link

mckeny3 commented May 25, 2023

`package com.mckenytech.swyfiodriver
import android.location.Location
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mckenytech.swyfiodriver.databinding.MapboxActivityNavigationViewBinding
import com.mapbox.api.directions.v5.models.RouteOptions
import com.mapbox.geojson.Point
import com.mapbox.maps.MapView
import com.mapbox.maps.plugin.gestures.OnMapLongClickListener
import com.mapbox.maps.plugin.gestures.gestures
import com.mapbox.navigation.base.extensions.applyDefaultNavigationOptions
import com.mapbox.navigation.base.extensions.applyLanguageAndVoiceUnitOptions
import com.mapbox.navigation.base.route.NavigationRoute
import com.mapbox.navigation.base.route.NavigationRouterCallback
import com.mapbox.navigation.base.route.RouterFailure
import com.mapbox.navigation.base.route.RouterOrigin
import com.mapbox.navigation.core.lifecycle.MapboxNavigationApp
import com.mapbox.navigation.core.trip.session.LocationMatcherResult
import com.mapbox.navigation.core.trip.session.LocationObserver
import com.mapbox.navigation.dropin.NavigationView
import com.mapbox.navigation.dropin.map.MapViewObserver
import com.mapbox.navigation.utils.internal.ifNonNull
import com.mapbox.navigation.utils.internal.logD

/**

  • The example demonstrates how to use [MapboxNavigationApp] to request routes outside [NavigationView]

  • and transition [NavigationView] to active navigation state.

  • Before running the example make sure you have put your access_token in the correct place

  • inside [app-preview/src/main/res/values/mapbox_access_token.xml]. If not present then add

  • this file at the location mentioned above and add the following content to it

  • <string name="mapbox_access_token"><PUT_YOUR_ACCESS_TOKEN_HERE></string>
    
  • The example uses replay location engine to facilitate navigation without physically moving.

  • How to use the example:

    • Start the example
    • Grant the location permissions if not already granted
    • Long press anywhere on the map
    • NavigationView should transition to active guidance
      */
      class NavigationViewActivity : AppCompatActivity(), OnMapLongClickListener {
      private var destination: Point? = null

    private var lastLocation: Location? = null
    private lateinit var binding: MapboxActivityNavigationViewBinding

    /**

    • Gets notified with location updates.

    • Exposes raw updates coming directly from the location services

    • and the updates enhanced by the Navigation SDK (cleaned up and matched to the road).
      */
      private val locationObserver = object : LocationObserver {
      override fun onNewLocationMatcherResult(locationMatcherResult: LocationMatcherResult) {
      lastLocation = locationMatcherResult.enhancedLocation
      }

      override fun onNewRawLocation(rawLocation: Location) {
      // no impl
      }
      }

    /**

    • Notifies with attach and detach events on [MapView]
      */
      private val mapViewObserver = object : MapViewObserver() {
      override fun onAttached(mapView: MapView) {
      mapView.gestures.addOnMapLongClickListener(
      this@NavigationViewActivity
      )
      }

      override fun onDetached(mapView: MapView) {
      mapView.gestures.removeOnMapLongClickListener(
      this@NavigationViewActivity
      )
      }
      }

    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val longitude = intent.getDoubleExtra("longitude", 0.0)
    val latitude = intent.getDoubleExtra("latitude", 0.0)
    destination = Point.fromLngLat(longitude, latitude)
    binding = MapboxActivityNavigationViewBinding.inflate(layoutInflater)
    setContentView(binding.root)

     // Set to false if you want to handle map long click listener in the app
     binding.navigationView.customizeViewOptions {
         enableMapLongClickIntercept = false
     }
    
     binding.navigationView.registerMapObserver(mapViewObserver)
     MapboxNavigationApp.current()?.registerLocationObserver(locationObserver)
    

// binding.startTripButton.setOnClickListener {
// ifNonNull(lastLocation, destination) { origin, destination ->
// requestRoutes(Point.fromLngLat(origin.longitude, origin.latitude), destination)
// }
// }

}

override fun onDestroy() {
    super.onDestroy()
    binding.navigationView.unregisterMapObserver(mapViewObserver)
    MapboxNavigationApp.current()?.unregisterLocationObserver(locationObserver)
}

override fun onMapLongClick(point: Point): Boolean {
    ifNonNull(lastLocation, destination) { origin, destination ->
        requestRoutes(Point.fromLngLat(origin.longitude, origin.latitude), destination)
        //log
        logD("origin: ${origin.longitude}, ${origin.latitude}")
    }
    return true
}

private fun requestRoutes(origin: Point, destination: Point) {
    MapboxNavigationApp.current()!!.requestRoutes(
        routeOptions = RouteOptions
            .builder()
            .applyDefaultNavigationOptions()
            .applyLanguageAndVoiceUnitOptions(this)
            .coordinatesList(listOf(origin, destination))
            .alternatives(true)
            .build(),
        callback = object : NavigationRouterCallback {
            override fun onCanceled(routeOptions: RouteOptions, routerOrigin: RouterOrigin) {
                // no impl
            }

            override fun onFailure(reasons: List<RouterFailure>, routeOptions: RouteOptions) {
                // no impl
            }

            override fun onRoutesReady(
                routes: List<NavigationRoute>,
                routerOrigin: RouterOrigin
            ) {
                binding.navigationView.api.routeReplayEnabled(true)
                binding.navigationView.api.startActiveGuidance(routes)
            }
        }
    )
}}// Pa`

@mckeny3
Copy link

mckeny3 commented May 25, 2023

thats my navigationView.kt...then this is the Navigationstarter to launch the activity `package com.mckenytech.swyfiodriver

import android.content.Intent
import android.widget.Toast
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod

internal class NavigationViewActivityStarter(reactContext: ReactApplicationContext?) :
ReactContextBaseJavaModule(reactContext) {
private var context: ReactApplicationContext = reactApplicationContext
override fun getName(): String {
return "RNMapboxNavigation"
}

@ReactMethod
fun navigateToExample() {
    Toast.makeText(context, "navigateToExample", Toast.LENGTH_LONG).show()
    val intent = Intent(context, NavigationViewActivity::class.java)
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    context.startActivity(intent)

    context.currentActivity?.startActivity(intent)

}

} this is my navigationPackager.ktpackage com.mckenytech.swyfiodriver

import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager

class NavigationViewReactPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List {
val modules: MutableList = ArrayList()
modules.add(NavigationViewActivityStarter(reactContext))
return modules
}

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
    return emptyList()
}

} then register your packager in MainApplicationActivitypackage com.mckenytech.swyfiodriver;

import android.app.Application;
import android.content.res.Configuration;
import androidx.annotation.NonNull;

import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;

import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;

import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
@OverRide
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

  @Override
  protected List<ReactPackage> getPackages() {
    @SuppressWarnings("UnnecessaryLocalVariable")
    List<ReactPackage> packages = new PackageList(this).getPackages();

// @generated begin implementation installer - expo prebuild (DO NOT MODIFY) sync-cb41cfe4a065c99a5a8fd5b134dc14d6b4d71981
packages.add(new NavigationViewReactPackage());

// @generated end implementation installer
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

  @Override
  protected String getJSMainModuleName() {
    return "index";
  }

  @Override
  protected boolean isNewArchEnabled() {
    return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
  }

  @Override
  protected Boolean isHermesEnabled() {
    return BuildConfig.IS_HERMES_ENABLED;
  }

});

@OverRide
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@OverRide
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load();
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}

@OverRide
public void onConfigurationChanged(@nonnull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
}
` now you will be able to launch it from the javascript side....this the latest mapbox ...10.13 and dropin ui 2.13 am using expo managed so i have to build config plugin to add all these...but if your useing bare workflow,you can add them directly

@Youssef-Durgham
Copy link

thats my navigationView.kt...then this is the Navigationstarter to launch the activity `package com.mckenytech.swyfiodriver

import android.content.Intent import android.widget.Toast import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactContextBaseJavaModule import com.facebook.react.bridge.ReactMethod

internal class NavigationViewActivityStarter(reactContext: ReactApplicationContext?) : ReactContextBaseJavaModule(reactContext) { private var context: ReactApplicationContext = reactApplicationContext override fun getName(): String { return "RNMapboxNavigation" }

@ReactMethod
fun navigateToExample() {
    Toast.makeText(context, "navigateToExample", Toast.LENGTH_LONG).show()
    val intent = Intent(context, NavigationViewActivity::class.java)
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    context.startActivity(intent)

    context.currentActivity?.startActivity(intent)

}

} this is my navigationPackager.ktpackage com.mckenytech.swyfiodriver

import com.facebook.react.ReactPackage import com.facebook.react.bridge.NativeModule import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.uimanager.ViewManager

class NavigationViewReactPackage : ReactPackage { override fun createNativeModules(reactContext: ReactApplicationContext): List { val modules: MutableList = ArrayList() modules.add(NavigationViewActivityStarter(reactContext)) return modules }

override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
    return emptyList()
}

} then register your packager in MainApplicationActivitypackage com.mckenytech.swyfiodriver;

import android.app.Application; import android.content.res.Configuration; import androidx.annotation.NonNull;

import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.soloader.SoLoader;

import expo.modules.ApplicationLifecycleDispatcher; import expo.modules.ReactNativeHostWrapper;

import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) { @OverRide public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; }

  @Override
  protected List<ReactPackage> getPackages() {
    @SuppressWarnings("UnnecessaryLocalVariable")
    List<ReactPackage> packages = new PackageList(this).getPackages();

// @generated begin implementation installer - expo prebuild (DO NOT MODIFY) sync-cb41cfe4a065c99a5a8fd5b134dc14d6b4d71981 packages.add(new NavigationViewReactPackage());

// @generated end implementation installer // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); return packages; }

  @Override
  protected String getJSMainModuleName() {
    return "index";
  }

  @Override
  protected boolean isNewArchEnabled() {
    return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
  }

  @Override
  protected Boolean isHermesEnabled() {
    return BuildConfig.IS_HERMES_ENABLED;
  }

});

@OverRide public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }

@OverRide public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { // If you opted-in for the New Architecture, we load the native entry point for this app. DefaultNewArchitectureEntryPoint.load(); } ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); ApplicationLifecycleDispatcher.onApplicationCreate(this); }

@OverRide public void onConfigurationChanged(@nonnull Configuration newConfig) { super.onConfigurationChanged(newConfig); ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig); } } ` now you will be able to launch it from the javascript side....this the latest mapbox ...10.13 and dropin ui 2.13 am using expo managed so i have to build config plugin to add all these...but if your useing bare workflow,you can add them directly

can I get your telegram user and In your free time, answer my question because I will officially go crazy.

@riyansghrt
Copy link

any solution for this issue ?

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

4 participants