0

出于某种原因,在我的调试器中打开了一个新选项卡,标题为:Activity.class标题说明:Class File Editor错误说明: The JAR file c:\sdk\platforms\android-17\android.jar has no source attachment。您可以通过单击下面的附加源来附加源。

从那里我尝试从我的工作区添加它,但它仍然不起作用(它只是说现在更改附加源)

日志猫:

09-10 14:52:25.744: I/System.out(23760): Sending WAIT chunk
09-10 14:50:58.191: D/dalvikvm(23118): Late-enabling CheckJNI
09-10 14:50:58.291: E/Trace(23118): error opening trace file: No such file or directory (2)
09-10 14:50:58.311: I/System.out(23118): Sending WAIT chunk
09-10 14:50:58.311: W/ActivityThread(23118): Application com.example.test is waiting for the debugger on port 8100...
09-10 14:50:58.331: I/dalvikvm(23118): Debugger is active
09-10 14:50:58.511: I/System.out(23118): Debugger has connected
09-10 14:50:58.521: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:58.721: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:58.922: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:59.122: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:59.322: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:59.522: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:59.722: I/System.out(23118): waiting for debugger to settle...
09-10 14:50:59.923: I/System.out(23118): debugger has settled (1375)
09-10 14:51:01.244: D/dalvikvm(23118): threadid=1: still suspended after undo (sc=1 dc=1)
09-10 14:51:46.202: D/dalvikvm(23118): Debugger has detached; object registry had 188 entries
09-10 14:51:46.202: I/dalvikvm(23118): ignoring registerObject request in thread=1
09-10 14:51:46.202: I/dalvikvm(23118): ignoring registerObject request in thread=1
09-10 14:51:46.352: D/libEGL(23118): loaded /system/lib/egl/libEGL_adreno200.so
09-10 14:51:46.352: D/libEGL(23118): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
09-10 14:51:46.352: D/libEGL(23118): loaded /system/lib/egl/libGLESv2_adreno200.so
09-10 14:51:46.352: I/Adreno200-EGL(23118): <qeglDrvAPI_eglInitialize:294>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB.04.01.01.00.036_msm8960_JB_CL2644550_release_AU (CL2644550)
09-10 14:51:46.352: I/Adreno200-EGL(23118): Build Date: 07/31/12 Tue
09-10 14:51:46.352: I/Adreno200-EGL(23118): Local Branch: 
09-10 14:51:46.352: I/Adreno200-EGL(23118): Remote Branch: quic/master
09-10 14:51:46.352: I/Adreno200-EGL(23118): Local Patches: NONE
09-10 14:51:46.352: I/Adreno200-EGL(23118): Reconstruct Branch: AU_LINUX_ANDROID_JB.04.01.01.00.036 +  NOTHING
09-10 14:51:46.382: D/OpenGLRenderer(23118): Enabling debug mode 0
09-10 14:52:25.704: E/Trace(23760): error opening trace file: No such file or directory (2)
09-10 14:52:25.724: W/ActivityThread(23760): Application com.example.test is waiting for the debugger on port 8100...
09-10 14:52:25.884: I/dalvikvm(23760): Debugger is active
09-10 14:52:25.944: I/System.out(23760): Debugger has connected
09-10 14:52:25.944: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:26.145: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:26.345: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:26.545: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:26.745: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:26.945: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:27.156: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:27.356: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:27.556: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:27.756: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:27.957: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:28.157: I/System.out(23760): waiting for debugger to settle...
09-10 14:52:28.357: I/System.out(23760): debugger has settled (1495)
09-10 14:52:28.617: D/dalvikvm(23760): threadid=1: still suspended after undo (sc=1 dc=1)
09-10 15:14:09.756: E/Trace(27219): error opening trace file: No such file or directory (2)
09-10 15:14:09.766: I/System.out(27219): Sending WAIT chunk
09-10 15:14:09.766: W/ActivityThread(27219): Application com.example.test is waiting for the debugger on port 8100...
09-10 15:14:09.786: I/dalvikvm(27219): Debugger is active
09-10 15:14:09.966: I/System.out(27219): Debugger has connected
09-10 15:14:09.966: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:10.176: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:10.376: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:10.577: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:10.777: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:10.977: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:11.177: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:11.377: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:11.578: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:11.778: I/System.out(27219): waiting for debugger to settle...
09-10 15:14:11.978: I/System.out(27219): debugger has settled (1496)
09-10 15:14:12.729: D/dalvikvm(27219): threadid=1: still suspended after undo (sc=1 dc=1)

来源:

package com.example.test;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.example.test.R;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends Activity {
    private TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.TextView01);
    }

    private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... urls) {
            String response = "";
            for (String url : urls) {
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url);
                try {
                    Document doc;
                    // need http protocol
                    doc = Jsoup.connect("http://google.com").get();

                    // get page title
                    String title = doc.title();
                    System.out.println("title : " + title);

                    // get all links
                    Elements links = doc.select("a[href]");
                    for (Element link : links) {

                        // get the value from href attribute
                        System.out.println("\nlink : " + link.attr("href"));
                        System.out.println("text : " + link.text());

                    }

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return response;
        }

        @Override
        protected void onPostExecute(String result) {
            textView.setText(result);
        }
    }

    public void onClick(View view) {
        DownloadWebPageTask task = new DownloadWebPageTask();
        task.execute(new String[] { "http://www.google.com" });
    }
}
4

3 回答 3

1

尝试关注

第 1 步:转到 adroid-sdk 安装文件夹。确保您有一个文件夹android-17,位于android-sdk/sources/

第2步:现在去Class File Editor tab。在那里你会看到一个带有标签的按钮'Attach source code'。单击它并获得选择外部文件夹的选项。并浏览直到你到达上面提到的 android-17 文件夹。选择它。它将附上源代码。

第 3 步:现在刷新项目。

第 4 步:现在再次检查Activityby的源代码ctrl+click.

就是这样,现在你可以看到Activity.

更新:

参考附上android源码

于 2013-09-10T19:51:50.150 回答
0

我不确定附加正确 Android 源的最简单方法,但 eclipse 尝试打开 Activity.class 的原因可能是发生了一些异常。

看看logcat。您应该能够在那里看到堆栈跟踪并找到原因,甚至不需要 Android 源代码。

于 2013-09-10T19:26:07.113 回答
0

发生这种情况是因为您快到了方法的末尾onCreate。然后控制返回到Activity调用您的onCreate方法的类。如果您稍后尝试在应用程序中调试某些内容,则应稍后在代码中设置断点。然而,一旦你完成了你的onCreate方法,你就真的没有什么可以调试的了。如果您想调试实际的 AndroidActivity类,您需要下载源代码并告诉 eclipse 在哪里可以找到它,尽管我怀疑这不是您想要做的。

于 2013-09-10T20:05:47.437 回答