0

我发布了一个应用程序,它使用谷歌地图的 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)
4

2 回答 2

1

我有同样的错误,似乎这个错误与 android-support-v4-googlemaps 的使用没有联系。

看看这个帖子:

MapView / MapActivity 在某些设备上崩溃

于 2013-03-07T16:20:45.413 回答
0

使用兼容性库时出现此错误。我所拥有的是针对 Android API 15 的项目,但我希望最低版本是 Android API 8,所以我需要兼容性库中的一些东西。我附上了图书馆,但忘了从中使用imports!项目建成时,一切正常,但是当我在装有 Android 2.3.3 的手机上运行它时,它找不到一些类,因为 Android 2.3.3 没有它们!所以,我建议你删除 all imports,按Ctrl+Shift+O,每当可以选择使用normalAndroid 内置类或兼容性库中的一个时,请始终选择第二个。告诉我它是否有帮助!

于 2012-06-15T19:11:29.567 回答