gpt4 book ai didi

java - 如何在Eclipse中读取调试日志

转载 作者:行者123 更新时间:2023-12-02 08:05:41 25 4
gpt4 key购买 nike

我正在运行以下代码......

package com.dc;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class DC extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
try
{
// this is the code that I am surrounding in the try/catch block
super.onCreate(savedInstanceState);

//init webview
WebView DCWebView = (WebView) findViewById(R.id.webview);

//when a link is clicked, use the WebView instead of opening a new browser
DCWebView.setWebViewClient(new MyWebViewClient() {
public void launchExternalBrowser(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
});

//enable javascript
WebSettings webViewSettings = DCWebView.getSettings();
webViewSettings.setJavaScriptEnabled(true);
}
catch (Exception e)
{
// this is the line of code that sends a real error message to the log
Log.e("ERROR", "ERROR IN CODE: " + e.toString());

// this is the line that prints out the location in
// the code where the error occurred.
e.printStackTrace();
}
}
}

这个堆栈跟踪并不是非常有帮助。我刚刚学习java/android(我有PHP背景)

11-20 21:22:43.892: ERROR/ERROR(1032): ERROR IN CODE: java.lang.NullPointerException
11-20 21:22:43.892: WARN/System.err(1032): java.lang.NullPointerException
11-20 21:22:43.902: WARN/System.err(1032): at com.dealclippings.DealClippings.onCreate(DealClippings.java:24)
11-20 21:22:43.902: WARN/System.err(1032): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-20 21:22:43.912: WARN/System.err(1032): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
11-20 21:22:43.912: WARN/System.err(1032): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
11-20 21:22:43.922: WARN/System.err(1032): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-20 21:22:43.922: WARN/System.err(1032): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
11-20 21:22:43.932: WARN/System.err(1032): at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 21:22:43.932: WARN/System.err(1032): at android.os.Looper.loop(Looper.java:123)
11-20 21:22:43.942: WARN/System.err(1032): at android.app.ActivityThread.main(ActivityThread.java:3647)
11-20 21:22:43.942: WARN/System.err(1032): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 21:22:43.952: WARN/System.err(1032): at java.lang.reflect.Method.invoke(Method.java:507)
11-20 21:22:43.952: WARN/System.err(1032): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-20 21:22:43.962: WARN/System.err(1032): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-20 21:22:43.962: WARN/System.err(1032): at dalvik.system.NativeStart.main(Native Method)

最佳答案

DealClippings 文件第 24 行出现 NullPointerException

java.lang.NullPointerException at   
com.dealclippings.DealClippings.onCreate(DealClippings.java:24)

关于java - 如何在Eclipse中读取调试日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8206671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com