Android - 我应该如何根据此异常跟踪修复错误?
根据开发者控制台上的崩溃报告,我的 Android 应用程序经常发生错误。
java.lang.NullPointerException
at android.widget.AbsListView.obtainView(AbsListView.java:1304)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
at android.widget.ListView.onMeasure(ListView.java:1109)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
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)
不幸的是,我无法在我的 Android 手机上复制该错误。
我不知道从哪里开始:在跟踪中没有任何对我的代码的引用。
有人可以给我一些关于如何确定问题根源的建议吗?
谢谢,
担
There is an error in my Android application that happens quite often, based on the crash report on the Developer Console.
java.lang.NullPointerException
at android.widget.AbsListView.obtainView(AbsListView.java:1304)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
at android.widget.ListView.onMeasure(ListView.java:1109)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
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)
Unfortunately, I can't replicate that error on my Android phone.
I dont' know where to start: in the trace there isn't any reference to my code.
Can somebody give me some suggestions on how to identify the root of the problem, please?
Thanks,
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能想到的最明显的事情:
AbsListView.obtainView()
我相信是与采用者通信以填充列表视图。确保永远不会出现将 null 返回到列表视图的情况。该平台的某些版本可能存在错误。不幸的是,开发人员控制台当前不向您显示错误报告来自的平台版本。希望将来会添加此功能以帮助诊断这种情况。
有人可能正在运行有错误的非标准或自定义版本的平台。您可以通过查看错误来源的不同设备的“平台”部分来确定这一点。
The most obvious things I can think of:
AbsListView.obtainView()
I believe is communicating with the Adopter to populate the list view. Make sure there is never a case where you could return a null back to the list view.There may be a bug in some version of the platform. Unfortunately the developer console does not currently show you the platform version the error reports came from. Hopefully this will be added in the future to help diagnose such a situation.
It is possible someone is running a non-standard or custom build of the platform that has bugs. You might be able to determine this by looking at the "platforms" section for the different devices the error is coming from.
我会尝试创建一个虚拟设备并将其加载到模拟器中,从最小的分辨率开始。
我怀疑这与屏幕尺寸有关,并且不知何故您试图绘制不存在的像素。
I would try creating a virtual device and load it in the emulator, start with the smallest resolution.
I am suspecting that it has to do with screen size and somehow you are trying to draw in a pixel that doesn't exist.