Cordova应用程序可以编译,但运行时会崩溃.如何获得错误报告? [英] Cordova app compiles but crashes on run. How to get error report?

查看:226
本文介绍了Cordova应用程序可以编译,但运行时会崩溃.如何获得错误报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Cordova应用程序,可以正确编译.但是,当我将应用程序午餐到我的android设备上时,它在启动时立即崩溃.当我不知道错误是什么时,我很难调试.

I have a Cordova app that compiles with no errors. However, when I lunch the app to my android device it instantly crashes on startup. I am having a hard time debugging when I do not know what the bug is…

问题:有没有办法从这次崩溃中获取错误报告?

我通常使用chrome调试我的应用程序,但只有在该应用程序能够在设备上加载并运行的情况下,它才起作用.

I usually use chrome to debug my app but that only works if the app is able to load and run on the device.

推荐答案

您索取了一些有关logcat的文章...我要在答案部分中添加内容,因为它太多了以致无法发表评论:)

You requested some article about logcat... I'm putting in the answer section since it is too much information for comments :)

DOCS

对于Android,您始终可以转到开发者页面.

In case of Android, you can always go to Developer's page.

这里是关于logcat的Android页面

HERE is the Android's page about logcat

如果您使用的是Android Studio,还可以检查 LINK

If you use android Studio, you can also check this LINK.

捕获

基本上,您可以使用以下命令捕获logcat:

Basically, you can capture logcat with following command:

adb logcat

您可以在命令中添加很多参数,这些参数可以帮助您过滤和显示所需的消息...这是个人的...我总是使用下面的命令来获取消息时间戳:

There's a lot of parameters you can add to command which helps you to filter and display the message that you want... This is personal... I always use the command below to get the message timestamp:

adb logcat -v time

您可以将输出重定向到文件并在文本编辑器中对其进行分析.

You can redirect the output to a file and analyze it in a Text Editor.

分析

如果您的应用崩溃了,您将得到类似的信息:

If you app is Crashing, you'll get something like:

07-09 08:29:13.474 21144-21144/com.example.khan.abc D/AndroidRuntime: Shutting down VM
07-09 08:29:13.475 21144-21144/com.example.khan.abc E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.khan.abc, PID: 21144
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.app.FragmentActivity.onBackPressed()' on a null object reference
     at com.example.khan.abc.AudioFragment$1.onClick(AudioFragment.java:125)
     at android.view.View.performClick(View.java:4848)
     at android.view.View$PerformClick.run(View.java:20262)
     at android.os.Handler.handleCallback(Handler.java:815)
     at android.os.Handler.dispatchMessage(Handler.java:104)
     at android.os.Looper.loop(Looper.java:194)
     at android.app.ActivityThread.main(ActivityThread.java:5631)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
07-09 08:29:15.195 21144-21144/com.example.khan.abc I/Process: Sending signal. PID: 21144 SIG: 9

日志的这一部分显示了很多信息:

This part of the log shows you a lot of information:

  • 问题发生时:07-09 08:29:13.475

检查问题发生的时间很重要...您可能在日志中发现一些错误...您必须确保检查的是正确的消息:)

It is important to check when the issue happened... You may find several errors in a log... you must be sure that you are checking the proper messages :)

  • 哪个应用崩溃了:com.example.khan.abc

这样,您就知道哪个应用程序崩溃了(以确保您正在检查有关消息的日志)

This way, you know which app crashed (to be sure that you are checking the logs about your message)

  • 哪个错误:java.lang.NullPointerException

NULL指针异常错误

A NULL Pointer Exception error

  • 有关该错误的详细信息:Attempt to invoke virtual method 'void android.support.v4.app.FragmentActivity.onBackPressed()' on a null object reference

您试图从FragmentActivity对象调用方法onBackPressed().但是,当您执行此操作时,该对象为null.

You tried to call method onBackPressed() from a FragmentActivity object. However, that object was null when you did it.

  • 堆栈跟踪:堆栈跟踪向您显示方法的调用顺序...有时,错误发生在调用方法中(而不是在被调用方法中).

  • Stack Trace: Stack Trace shows you the method invocation order... Sometimes, the error happens in the calling method (and not in the called method).

在com.example.khan.abc.AudioFragment $ 1.onClick(AudioFragment.java:125)

at com.example.khan.abc.AudioFragment$1.onClick(AudioFragment.java:125)

错误发生在文件com.example.khan.abc.AudioFragment.java中的onClick()方法内的行:125(stacktrace显示发生错误的行)

Error happened in file com.example.khan.abc.AudioFragment.java, inside onClick() method at line: 125 (stacktrace shows the line that error happened)

它的调用者是:

at android.view.View.performClick(View.java:4848)

谁被呼叫:

at android.view.View$PerformClick.run(View.java:20262)

由以下人员调用:

at android.os.Handler.handleCallback(Handler.java:815)

等...

概述

这只是概述...并非所有日志都很简单,等等...只是为了分享想法并为您提供入门级信息...

This was just an overview... Not all logs are simple etc... It is just to share the idea and provide a entry-level information to you...

我希望我能以某种方式帮助您... 问候

I hope I could help you someway... Regards

这篇关于Cordova应用程序可以编译,但运行时会崩溃.如何获得错误报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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