MapBox 9.2.0 вызывает ошибку sh in Android 8.0 (Oreo) JNI ОБНАРУЖЕНА ОШИБКА В ПРИЛОЖЕНИИ - PullRequest
0 голосов
/ 29 мая 2020

Проблем не было, но поскольку приложение перешло в фоновый режим через 3 или 5 минут, приложение вылетало. ОБНАРУЖЕННАЯ ОШИБКА JNI В ПРИЛОЖЕНИИ: не удается вызвать java .lang.Object java .lang.ref.Reference .get () в экземпляре java .lang.String при вызове CallObjectMethodV из void android .os.MessageQueue.nativePollOnce (long, int), и это то, что он показывает в журнале.

class HomeFragment : BaseFragment() {

@Inject
lateinit var factory: ViewModelProvider.Factory
lateinit var binding: HomeBinding
var anchorClicked: Boolean = false
private lateinit var mapboxMap: MapboxMap


override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    binding = inflater.bind(R.layout.fragment_home, container)
    return binding.root
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
    super.onActivityCreated(savedInstanceState)
    binding.handler = this
    binding.lifecycleOwner = viewLifecycleOwner
    binding.mapView.onCreate(savedInstanceState)
    val navigationView: NavigationView = requireActivity().findViewById(R.id.sideNV)
    val headerView = navigationView.getHeaderView(0)
    withViewModel<MapViewModel>(factory) {
        binding.mapView.getMapAsync { mapBoxMap ->
            this@HomeFragment.mapboxMap = mapBoxMap
            if (getCurrentTheme())
                mapBoxMap.setStyle(Style.TRAFFIC_NIGHT){
                    requestPermission(it)
                }
            else mapBoxMap.setStyle(Style.TRAFFIC_DAY){
                requestPermission(it)
            }
        }
        val auth = FirebaseAuth.getInstance()
        if (auth.currentUser != null) {
            val auth1 = FirebaseAuth.getInstance()
            if (auth1.currentUser != null) {
                headerView.userNameTV.text = auth1.currentUser?.displayName
                headerView.userEmailTV.text = auth1.currentUser?.email.toString()
                Glide.with(requireActivity())
                    .load(auth1.currentUser?.photoUrl)
                    .apply(RequestOptions.bitmapTransform(RoundedCorners(14)))
                    .into(headerView.userPicIV)
            }
        }
        binding.vm = this
        getCountries().observe(viewLifecycleOwner, Observer { })
    }
}

fun requestPermission(style:Style) {
    if (!hasPermissions(context, permissions)) requestPermissions(permissions, RC_LOCATION)
    else enableLocationComponent(style)
}

private fun enableLocationComponent(loadedMapStyle: Style) {
    val customLocationComponentOptions = LocationComponentOptions.builder(context!!)
        .trackingGesturesManagement(true)
        .accuracyColor(ContextCompat.getColor(context!!, R.color.com_facebook_blue))
        .build()

    val locationComponentActivationOptions =
        LocationComponentActivationOptions.builder(context!!, loadedMapStyle)
            .locationComponentOptions(customLocationComponentOptions)
            .build()

    mapboxMap.locationComponent.apply {
        activateLocationComponent(locationComponentActivationOptions)
        isLocationComponentEnabled = true
        cameraMode = CameraMode.TRACKING
        renderMode = RenderMode.COMPASS
    }
}


override fun onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<out String>,
    grantResults: IntArray
) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    if (requestCode == RC_LOCATION) {
        if (grantResults.isNotEmpty()
            && grantResults[0] == PackageManager.PERMISSION_GRANTED
        ) {
            enableLocationComponent(mapboxMap.style!!)
        }
    }
}

companion object {
    const val RC_LOCATION = 10
}

}

Это мой код. Это какое-то ограничение в oreo / проблема с блоком карты. Если да, что можно сделать, чтобы этого избежать. Можно ли использовать Coroutines для решения этой проблемы?

...