0

アクティビティから戻った後にGoogleMap( ) オブジェクトの状態を復元しようとすると、アプリが一貫してクラッシュします。カスタム サポート ライブラリ v4 ( ) にあり、それ自体が( ) に埋め込まれています。これらのコンポーネントのセットアップは正常です。私のデバイスは、プッシュ時にすべての を破棄するように開発者が構成しています。mapViewmapViewFragmentMyFragmentAppCompatActivityMyActivityActivity

別の をプッシュしてポップするとActivity、 myFragmentonCreateView(LayoutInflater, ViewGroup, Bundle state)メソッドが呼び出され、クラッシュします

  mapView.onCreate(state);

下部にトレースを生成します。

が の場合、最初の作成時にクラッシュは発生しませ。クラッシュは、MultiDex または Proguard を有効または無効にする (私が見つけた) 組み合わせによって解決されません。statenull

実際、私ができることは、Instant Run を有効にして Android Studio から直接実行することだけです。この場合、すべて問題ありません。Instant Run を無効にして Android Studio から実行すると、クラッシュが発生します。


アップデート:

先週、Google は Android Build Tools v5.0.1 と Google Play Services v10.0 をリリースしました。更新後、この問題は解消されたようです。ただし、他のアイデアが現れるかどうかを確認するために、この質問は開いたままにします。以下の Aлекс のアイデアは、私がとにかく試すことができる良いアイデアです。


11-11 13:37:42.165 18389 18389 E Parcel  : Class not found when unmarshalling: android.support.v7.widget.LinearLayoutManager$SavedState
11-11 13:37:42.165 18389 18389 E Parcel  : java.lang.ClassNotFoundException: android.support.v7.widget.LinearLayoutManager$SavedState
11-11 13:37:42.165 18389 18389 E Parcel  :  at java.lang.Class.classForName(Native Method)
11-11 13:37:42.165 18389 18389 E Parcel  :  at java.lang.Class.forName(Class.java:324)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Parcel.readParcelableCreator(Parcel.java:2404)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Parcel.readParcelable(Parcel.java:2358)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Parcel.readValue(Parcel.java:2264)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Parcel.readArrayMapInternal(Parcel.java:2614)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.BaseBundle.unparcel(BaseBundle.java:221)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Bundle.getBundle(Bundle.java:763)
11-11 13:37:42.165 18389 18389 E Parcel  :  at aby.a(:com.google.android.gms.DynamiteModulesB:74)
11-11 13:37:42.165 18389 18389 E Parcel  :  at maps.ad.t.a(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at maps.ad.R.a(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at xx.onTransact(:com.google.android.gms.DynamiteModulesB:66)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Binder.transact(Binder.java:387)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.maps.internal.IMapViewDelegate$zza$zza.onCreate(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.maps.MapView$zza.onCreate(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.dynamic.zza$3.zzb(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.dynamic.zza$1.zza(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.maps.MapView$zzb.zzbsp(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.maps.MapView$zzb.zza(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.dynamic.zza.zza(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.dynamic.zza.onCreate(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.gms.maps.MapView.onCreate(Unknown Source)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.myco.myapp.MyFragment.onCreateView(MyFragment.java:235)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.Fragment.performCreateView(Fragment.java:2087)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1113)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1295)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1277)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2154)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:603)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:181)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.myco.myapp.main.MainActivity.onStart(MainActivity.java:176)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.Activity.performStart(Activity.java:6916)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3218)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3351)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.ActivityThread.access$1100(ActivityThread.java:222)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Handler.dispatchMessage(Handler.java:102)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.os.Looper.loop(Looper.java:158)
11-11 13:37:42.165 18389 18389 E Parcel  :  at android.app.ActivityThread.main(ActivityThread.java:7230)
11-11 13:37:42.165 18389 18389 E Parcel  :  at java.lang.reflect.Method.invoke(Native Method)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
11-11 13:37:42.165 18389 18389 E Parcel  : Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.LinearLayoutManager$SavedState" on path: DexPathList[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000018/DynamiteModulesB_GmsCore_prodmnc_hdpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/00000018/n/armeabi-v7a, /data/user/0/com.google.android.gms/app_chimera/m/00000018/n/armeabi, /vendor/lib, /system/lib]]
11-11 13:37:42.165 18389 18389 E Parcel  :  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-11 13:37:42.165 18389 18389 E Parcel  :  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-11 13:37:42.165 18389 18389 E Parcel  :  at com.google.android.chimera.container.internal.DelegateLastPathClassLoader.loadClass(:com.google.android.gms:34)
11-11 13:37:42.165 18389 18389 E Parcel  :  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
11-11 13:37:42.165 18389 18389 E Parcel  :  ... 44 more
11-11 13:37:42.165 18389 18389 E Parcel  :  Suppressed: java.lang.ClassNotFoundException: android.support.v7.widget.LinearLayoutManager$SavedState
11-11 13:37:42.165 18389 18389 E Parcel  :      at java.lang.Class.classForName(Native Method)
11-11 13:37:42.165 18389 18389 E Parcel  :      at java.lang.BootClass
11-11 13:37:42.170 18389 18389 D AndroidRuntime: Shutting down VM
11-11 13:37:42.170 18389 18389 E AndroidRuntime: FATAL EXCEPTION: main
11-11 13:37:42.170 18389 18389 E AndroidRuntime: Process: com.myco.myapp, PID: 18389
11-11 13:37:42.170 18389 18389 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myco.myapp/com.myco.myapp.main.MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.LinearLayoutManager$SavedState
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3255)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3351)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.ActivityThread.access$1100(ActivityThread.java:222)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:158)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7230)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
11-11 13:37:42.170 18389 18389 E AndroidRuntime: Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.LinearLayoutManager$SavedState
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Parcel.readParcelableCreator(Parcel.java:2432)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Parcel.readParcelable(Parcel.java:2358)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Parcel.readValue(Parcel.java:2264)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Parcel.readArrayMapInternal(Parcel.java:2614)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.BaseBundle.unparcel(BaseBundle.java:221)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Bundle.getBundle(Bundle.java:763)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at aby.a(:com.google.android.gms.DynamiteModulesB:74)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at maps.ad.t.a(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at maps.ad.R.a(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at xx.onTransact(:com.google.android.gms.DynamiteModulesB:66)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.os.Binder.transact(Binder.java:387)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.maps.internal.IMapViewDelegate$zza$zza.onCreate(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.maps.MapView$zza.onCreate(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.dynamic.zza$3.zzb(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.dynamic.zza$1.zza(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.maps.MapView$zzb.zzbsp(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.maps.MapView$zzb.zza(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.dynamic.zza.zza(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.dynamic.zza.onCreate(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.google.android.gms.maps.MapView.onCreate(Unknown Source)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.myco.myapp.MyFragment.onCreateView(MyFragment.java:235)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.Fragment.performCreateView(Fragment.java:2087)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1113)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1295)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1277)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2154)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:603)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:181)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at com.myco.myapp.main.MainActivity.onStart(MainActivity.java:176)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.Activity.performStart(Activity.java:6916)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3218)
11-11 13:37:42.170 18389 18389 E AndroidRuntime:    ... 9 more
11-11 13:37:42.175  2546  3527 W ActivityManager:   Force finishing activity com.myco.myapp/.main.MainActivity
4

1 に答える 1

1

マップの状態を別のバンドルに保存してから、このバンドルをフィールドとしてフラグメントの状態バンドルに入れる必要があります。フラグメントの状態を復元するときは、フラグメントの復元状態バンドルからマップのバンドルを抽出し、それをマップの復元状態メソッドに送信します。

于 2016-11-24T14:02:44.763 に答える