Activity.class - Class File Editor: The JAR file c:\sdk\platforms\android-17\android.jar has no source attachment

这一生的挚爱 提交于 2019-12-13 04:36:46

问题


For some reason a new tab opens in my debugger titled: Activity.class with a header stating: Class File Editor and the error stating: The JAR file c:\sdk\platforms\android-17\android.jar has no source attachment. You can attach a source by clicking attach source below.

From there I tried adding it from my workspace however it still does not work (it simply says change attached source now instead)

LOGCAT:

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)

SOURCE:

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" });
    }
}

回答1:


Try following

Step 1 : Go to the adroid-sdk install folder.Make sure you have a folder android-17, at android-sdk/sources/

Step 2 : Now go to Class File Editor tab. There you will see a button with label 'Attach source code'. Click it and get the option to select an external folder. And browse till you reach above mentioned android-17 folder. Select it. It will attach the source code.

Step 3 : Now refresh the project.

Step 4 : Now again check the source code of Activity by ctrl+click.

That's it, now you can see the source code for Activity.

UPDATE:

Refer attach android source




回答2:


I am not sure about the easiest way to attach the correct Android source, but the reason eclipse tries to open Activity.class is probably that some exception occurred.

Take a look at logcat. You should be able to see a stack trace there and find the reason without even needing the Android source code.




回答3:


This is happening because you're reaching the end of the method onCreate. Control is then returning to the Activity class which called your onCreate method. If you're trying to debug something later in your application, you should set the break point later in your code. However, once you reach the end of your onCreate method, there's really nothing left for you to debug. If you wish to debug the actual Android Activity class, you'll need to download the source and tell eclipse where to find it, although I suspect that's not what you want to do.



来源:https://stackoverflow.com/questions/18727049/activity-class-class-file-editor-the-jar-file-c-sdk-platforms-android-17-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!