如何调试这个空指针异常?指针、异常

2023-09-03 23:09:37 作者:柠檬不该羡慕西瓜的甜

我想写为Android的应用程序,当我启动我的新活动,我给自己定个破发点,并发现它贯穿我的onCreate没有任何错误,但该函数返回后,调试器说,有一个空指针异常。现在的问题是,它不是在我的code,它说,它在ActivityThread.performLaunchActivity(ActivityThread $ ActivityRecord)线:2268,并在源通常是(如果它是我的code)我只是得到源未找到。和一个按钮,上面写着编辑源查找路径

I'm trying to write an application for Android and when I launch my new activity, I've set break points and found that it runs through my onCreate without any errors, but after that function returns, the debugger says there is a NullPointer Exception. The problem is, its not in my code, it says its in ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268 and where the source normally would be (if it were my code) I just get "Source not found." and a button that says "Edit Source Lookup Path"

我如何设置日食这样我就可以调试这个问题?我敢肯定,我做错了什么在我的code,但由于异常code源于我看不到,我不知道如何找出问题所在。

How can I setup eclipse so I can debug this problem? I'm sure I'm doing something wrong in my code, but because the exception originates in code I can't see, I have no idea how to figure out where the problem is.

我使用的是Android的SDK-linux_x86-1.5_r3和我的G1为这个项目。

I'm using android-sdk-linux_x86-1.5_r3 and my G1 for this project.

更新:我想我的问题其实更多的是比使用Eclipse的Andr​​oid开发。我不知道在哪里可以找到源的code被抛出异常。也许有一个办法,我有没有这样的文件可以调试它,但我不知道会是怎样。

UPDATE: I think my question really has more to do with android development than using eclipse. I'm not sure where to find the source for the the code that is throwing the exception. Maybe there is a way I can debug it without having that file, but I'm not sure what it would be.

推荐答案

您打算在假设应该是NPE是由你造成的,而不是机器人。该NPE可能会弹出在 ActivityThread.performLaunchActivity(ActivityThread $ ActivityRecord)线:2268 但是这意味着你传递一个空指针的东西,并不停地获得通过,直到周围的 performLaunchActivity 真正尝试使用它坠毁时,它发现了一个空指针。

Your going in assumption should be the NPE is caused by you, not Android. The NPE may pop at ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268 but that means you passed a null pointer to something and it kept on getting passed around until performLaunchActivity actually tried using it and crashed when it found a null pointer.

如果我们能看到完整的LogCat中,特别是一切都在红在Eclipse LogCat中,这将有助于进行调试。我转念内而外寻找一个NPE只为别人找到一个非常微妙的资源初始化线出来的地方。

If we can see the full LogCat, particularly everything in red in the Eclipse LogCat it would help for debugging. I've turned myself inside out looking for an NPE only for someone else to find a very subtle resource initializing line out of place.

 
精彩推荐
图片推荐