如何获得code中的特定行抛出一个错误 [英] How to get the specific line of code that threw an error

查看:118
本文介绍了如何获得code中的特定行抛出一个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个显示java.lang.NullPointerException权当应用程序启动并关闭。从模拟器的错误是不幸的是,应用程序的名字已经停止。这是工作的罚款,直到我写了一堆新的code,并改变了清单。但愿这不是明显的,但我的问题是,我怎么能找出行code是什么问题?跟踪转储对我毫无意义,即使它的冗长,有... 11多个没有让我看到了整个事情。

我真的不知道这是什么错误意味着。我搜索了它,但似乎有东西,这可能意味着一个列表。我已经试过项目>清洁,我试着清单再次搞乱,但我仍然得到错误。我已经选中/取消外部库。刚刚做了什么人建议做其他人得到同样的错误。所以我很想知道,是什么线将其取消?

下面是输出,如果这会有所帮助:

  8月6号至29号:37:23.680:E / AndroidRuntime(1225):致命异常:主要
八月六日至29日:37:23.680:E / AndroidRuntime(1225):java.lang.RuntimeException的:无法实例活动ComponentInfo {com.upliftly.android/com.upliftly.android.UpliftlyActivity}:显示java.lang.NullPointerException
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.ActivityThread.access $ 600(ActivityThread.java:122)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1146)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.os.Handler.dispatchMessage(Handler.java:99)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.os.Looper.loop(Looper.java:137)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.ActivityThread.main(ActivityThread.java:4340)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在java.lang.reflect.Method.invokeNative(本机方法)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在java.lang.reflect.Method.invoke(Method.java:511)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在dalvik.system.NativeStart.main(本机方法)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):由:显示java.lang.NullPointerException
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:101)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在com.upliftly.android.UpliftlyActivity< INIT>(UpliftlyActivity.java:19)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在java.lang.Class.newInstanceImpl(本机方法)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在java.lang.Class.newInstance(Class.java:1319)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.Instrumentation.newActivity(Instrumentation.java:1023)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
八月六日至29日:37:23.680:E / AndroidRuntime(1225):11 ...更多
 

解决方案

通常当你看到像你发布一个堆栈跟踪,你应该在行之后最后集中

 产生的原因:
 

行。在此之后,发现这是有你的包名就行,这是(在大多数情况下),从您的code导致异常的行。在您贴出的堆栈跟踪,该行是

 在com.upliftly.android.UpliftlyActivity< INIT>(UpliftlyActivity.java:19)
 

I'm getting a java.lang.NullPointerException right when the app launches and it shuts down. The error from the emulator is "Unfortunately, appname has stopped". It was working fine, until I wrote a bunch of new code, and changed the manifest. Hopefully it's not the manifest, but my question is, how can I find out what line of code is the problem? The trace dump means nothing to me, and even though it's verbose, having ...11 more doesn't let me see the whole thing.

I don't really know what that error means. I've searched for it, but there seems to be a list of things it could mean. I've tried Project>Clean, I've tried messing with the manifest again, but I still get the error. I've checked/unchecked external libraries. Just done what people have suggested to do for other people getting the same error. So I'd really like to know, what line set it off?

Here is the output if this helps:

06-29 08:37:23.680: E/AndroidRuntime(1225): FATAL EXCEPTION: main
06-29 08:37:23.680: E/AndroidRuntime(1225): java.lang.RuntimeException: Unable to    instantiate activity      ComponentInfo{com.upliftly.android/com.upliftly.android.UpliftlyActivity}: java.lang.NullPointerException
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.ActivityThread.access$600(ActivityThread.java:122)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.os.Looper.loop(Looper.java:137)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.ActivityThread.main(ActivityThread.java:4340)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at java.lang.reflect.Method.invokeNative(Native Method)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at java.lang.reflect.Method.invoke(Method.java:511)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at dalvik.system.NativeStart.main(Native Method)
06-29 08:37:23.680: E/AndroidRuntime(1225): Caused by: java.lang.NullPointerException
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:101)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at com.upliftly.android.UpliftlyActivity.<init>(UpliftlyActivity.java:19)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at java.lang.Class.newInstanceImpl(Native Method)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at java.lang.Class.newInstance(Class.java:1319)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
06-29 08:37:23.680: E/AndroidRuntime(1225):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
06-29 08:37:23.680: E/AndroidRuntime(1225):     ... 11 more

解决方案

Usually when you see a stack trace like the one you posted, you should focus in the lines after the last

Caused by: 

line. After that, detect the line that is has your package name and it is (in most cases) that line that caused the exception from your code. In the stack trace that you posted, that line is

at com.upliftly.android.UpliftlyActivity.<init>(UpliftlyActivity.java:19)

这篇关于如何获得code中的特定行抛出一个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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