AnsweredAssumed Answered

ArcGIS map crashes under android ViewPager2

Question asked by rsoe.fejlesztes on Jun 8, 2020
Latest reply on Jun 30, 2020 by gheppner-esristaff

Dear Esri Community!


My question might be a rookie one, I feel like I'm missing something very basic. I tried to make an ArcGIS map work under an android ViewPager2 structure. The map diplays nicely but when I navigate away to another fragment in the view pager, then back to the map, the app crashes with the following exception.


com.esri.arcgisruntime.ArcGISRuntimeException: vector: 
/home/jenkins/100.7.0/dev_android_java_RTCA_release/runtimecore/c_api/src/mapping/map_view/geo_view.cpp(701) : error : Exception caught in __FUNCTION__
    at com.esri.arcgisruntime.internal.jni.CoreGeoView.nativeDraw(Native Method)
    at com.esri.arcgisruntime.internal.jni.CoreGeoView.a(SourceFile:346)
    at com.esri.arcgisruntime.internal.h.b.o.a(SourceFile:132)
    at com.esri.arcgisruntime.mapping.view.MapView.onDrawFrame(SourceFile:156)
    at com.esri.arcgisruntime.mapping.view.GeoView$b.onDrawFrame(SourceFile:1363)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(
    at android.opengl.GLSurfaceView$

This seems to happen every time when the onResume() method of the Fragment containing the MapView is called. In this function (ie. the onResume()) I manually call onResume() on the MapView instance as indicated in this walkthrough:


I extracted the problematic part of the code to a test app, I removed all layers, now it's just an empty basemap in an empty app (under the view pager structure) and the crash persists.


The reason why I think this problem could be connected with the ViewPager2 is because in a previous version of the app, I used a different navigation structure without the view pager and the map was working fine.


The difference between my actual code and the above walkthrough is that it puts the MapView directly under the MainActivity while I put it in a fragment as I'm working with a view pager.


It was not absolutely clear to me if I still have to put the appropriate onPause(), onResume(), onDestroy() calls under the fragment class or under the main activity so I tried both (you can see the former in the code below) and I also tried removing those override functions completely. The exception was the same in each case.


Here is the test app MainActivity class building the view pager.


class MainActivity : AppCompatActivity() {

    private lateinit var adapter: ViewPagerFragmentAdapter
    private lateinit var viewPager: ViewPager2

    override fun onCreate(savedInstanceState: Bundle?) {

        adapter = ViewPagerFragmentAdapter(supportFragmentManager, lifecycle)
        viewPager = findViewById(
        viewPager.adapter = adapter


And the MapFragment class.


class MapFragment: Fragment() {

    lateinit var mMapView: MapView

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.fragment_map, container, false)

        mMapView = view.findViewById(

        val basemapType = Basemap.Type.IMAGERY_WITH_LABELS
        val latitude = 48.0166175
        val longitude = 19.0339708
        val levelOfDetail = 2 = ArcGISMap(basemapType, latitude, longitude, levelOfDetail)

        return view

    override fun onPause() {
        if (mMapView != null) {

    override fun onResume() {
        if (mMapView != null) {

    override fun onDestroy() {
        if (mMapView != null) {

Could you please give me any indicaton on where I could go wrong?


Thank you very much for any help in advance!