Android的 - 在某些设备上的共享preferences崩溃。 [英] Android - Shared Preferences crashes on some devices.

查看:252
本文介绍了Android的 - 在某些设备上的共享preferences崩溃。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的例外,我在崩溃报告得到的Andr​​oid:

I have this exception that I get in my crash reports from Android:

java.lang.NoSuchMethodError: android.content.SharedPreferences$Editor.apply
at com.problemio.ProblemioActivity.first_time_check(ProblemioActivity.java:231)
at com.problemio.ProblemioActivity.onCreate(ProblemioActivity.java:47)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4668)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)

我是pretty新Android中崩溃报告系统。为什么会这样崩溃发生的呢?我不能复制我的设备或模拟器上。

I am pretty new to the crash reporting system in Android. Why would this crash happen? I can not reproduce it on my device or the simulator.

从崩溃报告需要其他什么信息,以确定原因以及如何解决这一问题?

What other info is needed from the crash report to determine the cause and how to fix this?

谢谢!

推荐答案

<一个href=\"http://developer.android.com/reference/android/content/Shared$p$pferences.Editor.html#apply%28%29\"相对=nofollow> 适用() 在API级别9介绍,并运行你的应用程序某些设备可能会以较低的版本。考虑改变这种调用提交。正如在文档中阐明的:

apply() was introduced in API level 9, and some devices that runs your app may be with lower version. consider changing this call to commit. As stated in the docs:

的共享preferences.Editor接口预计不会
  直接实现。但是,如果previously没有实现,而且
  现在得到有关缺少适用()的错误,你可以简单地调用
  提交()从应用()。

The SharedPreferences.Editor interface isn't expected to be implemented directly. However, if you previously did implement it and are now getting errors about missing apply(), you can simply call commit() from apply().

这篇关于Android的 - 在某些设备上的共享preferences崩溃。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆