如何跨preT logcat的preT、logcat

2023-09-11 12:09:26 作者:做最好的自己

谁能告诉我,我应该怎么读的logcat错误?我想明白的地方我的问题是,在现阶段,我试着读它,但无法找到失事的原因。

下面是我的logcat不明白:

  05-18 18:29:44.160:ERROR / AndroidRuntime(2145):致命异常:主要
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.paad.whereami / com.paad.whereami.WhereAmI}:显示java.lang.NullPointerException
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.ActivityThread.access $ 1500(ActivityThread.java:117)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:931)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.os.Handler.dispatchMessage(Handler.java:99)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.os.Looper.loop(Looper.java:130)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.ActivityThread.main(ActivityThread.java:3683)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在java.lang.reflect.Method.invokeNative(本机方法)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在java.lang.reflect.Method.invoke(Method.java:507)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在dalvik.system.NativeStart.main(本机方法)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):由:显示java.lang.NullPointerException
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在com.paad.whereami.WhereAmI.updateWithNewLocation(WhereAmI.java:290)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在com.paad.whereami.WhereAmI.onCreate(WhereAmI.java:216)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-18 18:29:44.160:ERROR / AndroidRuntime(2145):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
 

解决方案

你的日志的第二个部分将是什么在这种情况下对你很重要。

  

引起的:   显示java.lang.NullPointerException

这意味着,放在你的code的东西设置为,你要使用它,就好像它不是。

接下来的几行告诉你,在你的code,你可以找到错误。

  

在com.paad.whereami.WhereAmI.updateWithNewLocation(WhereAmI.java:290)   在com.paad.whereami.WhereAmI.onCreate(WhereAmI.java:216)

Android Studio的LogCat在哪里

这应该意味着你有一个名为方法 updateWithNewLocation 你是从的onCreate 停靠线216。错误是从这个方法里面传在行290拿在code看看行290。因为事情是无论你正在尝试做该行导致异常不应该。

Can anyone tell me how I should read the errors in Logcat? I'd like to understand where my problem is, at the moment I try to read it but can't find the cause of the crash.

Here's the Logcat I don't understand:

05-18 18:29:44.160: ERROR/AndroidRuntime(2145): FATAL EXCEPTION: main
05-18 18:29:44.160: ERROR/AndroidRuntime(2145): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.paad.whereami/com.paad.whereami.WhereAmI}: java.lang.NullPointerException
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.os.Looper.loop(Looper.java:130)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at java.lang.reflect.Method.invokeNative(Native Method)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at java.lang.reflect.Method.invoke(Method.java:507)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at dalvik.system.NativeStart.main(Native Method)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145): Caused by: java.lang.NullPointerException
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.paad.whereami.WhereAmI.updateWithNewLocation(WhereAmI.java:290)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.paad.whereami.WhereAmI.onCreate(WhereAmI.java:216)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)

解决方案

The second "part" of your log is going to be what is important for you in this instance.

Caused by: java.lang.NullPointerException

This means that somewhere in your code something is set to null and you are trying to use it as though it isn't.

The next few lines tell you where in your code you can find the error.

at com.paad.whereami.WhereAmI.updateWithNewLocation(WhereAmI.java:290) at com.paad.whereami.WhereAmI.onCreate(WhereAmI.java:216)

This should mean that you have a method named updateWithNewLocation that you are calling from onCreate at line 216. The error is coming from inside this method at line 290. Take a look at line 290 in your code. Whatever you are trying to do on that line is causing the exception because something is null that shouldn't be.