Привет! Я работаю с этим SDK для android, и я продолжаю получать эту ошибку. У моего проекта есть навигационный ящик, и я пытаюсь получить карту в одном из ее фрагментов, здесь SDK - это мой XML и Kotlin код и ошибка моя ошибка:
java.lang.ClassCastException: com.here.android.mpa.mapping.MapView cannot be cast to com.here.android.mpa.mapping.AndroidXMapFragment
at com.example.pplin_mobilite.ui.Passager.PassagerFragment.onActivityCreated(PassagerFragment.kt:22)
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2717)
at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:346)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1188)
at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6758)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)
мой kotlin класс:
class PassagerFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
// Search for the Map Fragment
val mapFragment = map_frag as AndroidXMapFragment
// initialize the Map Fragment and
// retrieve the map that is associated to the fragment
mapFragment.init { error ->
if (error == OnEngineInitListener.Error.NONE) {
// now the map is ready to be used
mapFragment.map
// ...
} else {
println("ERROR: Cannot initialize AndroidXMapFragment")
}
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_notifications,container,false)
}
}
и мой xml:
<fragment
class="com.here.android.mpa.mapping.AndroidXMapFragment"
android:id="@+id/map_frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>