当调用onSaveInstanceState时,lite模式下的MapView崩溃

时间:2017-02-15 18:54:18

标签: android google-play-services android-mapview kotlin

当我使用LiteView模式的MapView时,在MapView对象上调用onSaveInstanceState()方法会导致应用程序崩溃。

这是stacktrace:

java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.b(android.os.Bundle)' on a null object reference
                                                                             at com.google.maps.api.android.lib6.impl.da.b(:com.google.android.gms.DynamiteModulesB:117)
                                                                             at com.google.android.gms.maps.internal.z.onTransact(:com.google.android.gms.DynamiteModulesB:108)
                                                                             at android.os.Binder.transact(Binder.java:507)
                                                                             at com.google.android.gms.maps.internal.IMapViewDelegate$zza$zza.onSaveInstanceState(Unknown Source)
                                                                             at com.google.android.gms.maps.MapView$zza.onSaveInstanceState(Unknown Source)
                                                                             at com.google.android.gms.dynamic.zza.onSaveInstanceState(Unknown Source)
                                                                             at com.google.android.gms.maps.MapView.onSaveInstanceState(Unknown Source)
                                                                             at ru.mail.sporttogether.fragments.AbstractMapFragment.onSaveInstanceState(AbstractMapFragment.kt:17)
                                                                             at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:2353)
                                                                             at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2599)
                                                                             at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2670)
                                                                             at android.support.v4.app.FragmentController.saveAllState(FragmentController.java:134)
                                                                             at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:571)
                                                                             at android.support.v7.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:509)
                                                                             at ru.mail.sporttogether.mvp.PresenterActivity.onSaveInstanceState(PresenterActivity.kt:91)
                                                                             at android.app.Activity.performSaveInstanceState(Activity.java:1502)
                                                                             at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1308)
                                                                             at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:5008)
                                                                             at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4286)
                                                                             at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4345)
                                                                             at android.app.ActivityThread.-wrap28(ActivityThread.java)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1684)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                             at android.os.Looper.loop(Looper.java:154)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:6688)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

XML

<com.google.android.gms.maps.MapView
                android:id="@+id/map_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:cameraZoom="17"
                app:layout_collapseMode="parallax"
                app:liteMode="true" />

代码示例

package ru.mail.sporttogether.fragments

import android.os.Bundle
import com.google.android.gms.maps.MapView
import ru.mail.sporttogether.mvp.MapPresenter
import ru.mail.sporttogether.mvp.PresenterFragment

abstract class AbstractMapFragment<T : MapPresenter> :
        PresenterFragment<T>() {
    protected lateinit var mapView: MapView

    override fun onSaveInstanceState(outState: Bundle?) {
        super.onSaveInstanceState(outState)
        mapView.onSaveInstanceState(outState)
    }

    override fun onLowMemory() {
        super.onLowMemory()
        mapView.onLowMemory()
    }

    override fun onStart() {
        super.onStart()
        mapView.onStart()
    }

    override fun onStop() {
        mapView.onStop()
        super.onStop()
    }

    override fun onPause() {
        mapView.onPause()
        super.onPause()
    }

    override fun onResume() {
        super.onResume()
        mapView.onResume()
    }

    override fun onDestroyView() {
        super.onDestroyView()
        mapView.onDestroy()
    }
}

在onCreateView()方法中的其他片段中,我在MapView对象上调用onCreate()和getMapAsync()。 如果仅在lite模式下使用MapView,我有这个问题。 这是GP服务的内部错误吗?

0 个答案:

没有答案