我发布了一个应用程序,它使用谷歌地图的 Android 兼容性库 ( https://github.com/petedoyle/android-support-v4-googlemaps ),我收到了一些奇怪的“无法启动活动”崩溃报告。
我在下面粘贴了几个示例堆栈跟踪。有其他人使用 Google Maps 的 Android 兼容性库,甚至使用标准的 Android 兼容性库 ( http://developer.android.com/sdk/compatibility-library.html ) 体验过吗?任何人都知道我如何能够克服这个错误?
----- 示例堆栈跟踪 1 -----
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myapp/com.mycompany.myapp.activities.GameActivity}: java.lang.NullPointerException
...
caused by java.lang.NullPointerException
at android.app.ContextImpl.openFileOutput(ContextImpl.java:430)
at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
at com.google.common.io.android.AndroidPersistentStore.writeBlockX(Unknown Source)
at com.google.common.io.android.AndroidPersistentStore.writeBlock(Unknown Source)
at com.google.common.io.PreferenceStore.ensurePreferencesLoaded(Unknown Source)
at com.google.common.io.PreferenceStore.readPreference(Unknown Source)
at com.google.common.io.BasePersistentStore.readPreference(Unknown Source)
at com.google.common.StaticUtil.readPreferenceAsDataInput(Unknown Source)
at com.google.googlenav.datarequest.DataRequestDispatcher.loadOrRequestCookie(Unknown Source)
at com.google.googlenav.datarequest.DataRequestDispatcher.<init>(Unknown Source)
at com.google.googlenav.datarequest.DataRequestDispatcher.createInstance(Unknown Source)
at com.google.android.maps.MapActivity.createMap(MapActivity.java:509)
at com.google.android.maps.MapActivity.onCreate(MapActivity.java:409)
at android.support.v4.app.FragmentActivity.onCreate(Unknown Source)
at com.mycompany.myapp.activities.GameActivity.onCreate(Unknown Source)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
----- 示例堆栈跟踪 2 -----
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myapp/com.mycompany.myapp.activities.GameActivity}: java.lang.NullPointerException
...
Caused by: java.lang.NullPointerException
at android.app.ContextImpl.openFileOutput(ContextImpl.java:423)
at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
at android_maps_conflict_avoidance.com.google.common.io.android.AndroidPersistentStore.writeBlockX(AndroidPersistentStore.java:140)
at android_maps_conflict_avoidance.com.google.common.io.android.AndroidPersistentStore.writeBlock(AndroidPersistentStore.java:169)
at android_maps_conflict_avoidance.com.google.common.io.PreferenceStore.ensurePreferencesLoaded(PreferenceStore.java:178)
at android_maps_conflict_avoidance.com.google.common.io.PreferenceStore.readPreference(PreferenceStore.java:86)
at android_maps_conflict_avoidance.com.google.common.io.BasePersistentStore.readPreference(BasePersistentStore.java:41)
at android_maps_conflict_avoidance.com.google.common.StaticUtil.readPreferenceAsDataInput(StaticUtil.java:271)
at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.loadOrRequestCookie(DataRequestDispatcher.java:493)
at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.<init>(DataRequestDispatcher.java:390)
at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.createInstance(DataRequestDispatcher.java:341)
at com.google.android.maps.MapActivity.createMap(MapActivity.java:548)
at com.google.android.maps.MapActivity.onCreate(MapActivity.java:422)
at android.support.v4.app.FragmentActivity.onCreate(Unknown Source)
at com.mycompany.myapp.activities.GameActivity.onCreate(Unknown Source)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1709)