• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

problem running HelloWorld app in Eclipse

Hello, World | Android Developers

Eclipse 3.7
SDK 3.2, 3.0, 2.3.3
Hierarchy Viewer version: 12.0.0.v201106281929-138431
Android Development Toolkit version: 12.0.0.v201106281929-138431

I tried running the helloworld app on all three target build platforms with a AVD selected for each one appropriately.

I am getting this error consistently:

Code:
[2011-08-07 21:55:04 - hierarchyviewer]Unable to get view server version from device emulator-5554
[2011-08-07 21:55:44 - hierarchyviewer]Unable to get view server protocol version from device emulator-5554

It also runs very slowly (in excess of 60 secs on Ubuntu 11.04).

I found the code that throws these exceptions in the com.android.hierarchyviewerlib.device.DeviceBridge class.

Here is the method involved:

Code:
public static ViewServerInfo loadViewServerInfo(IDevice device) {
        int server = -1;
        int protocol = -1;
        DeviceConnection connection = null;
        try {
            connection = new DeviceConnection(device);
            connection.sendCommand("SERVER"); //$NON-NLS-1$
            String line = connection.getInputStream().readLine();
            if (line != null) {
                server = Integer.parseInt(line);
            }
        } catch (Exception e) {
            Log.e(TAG, "Unable to get view server version from device " + device);
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
        connection = null;
        try {
            connection = new DeviceConnection(device);
            connection.sendCommand("PROTOCOL"); //$NON-NLS-1$
            String line = connection.getInputStream().readLine();
            if (line != null) {
                protocol = Integer.parseInt(line);
            }
        } catch (Exception e) {
            Log.e(TAG, "Unable to get view server protocol version from device " + device);
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
        if (server == -1 || protocol == -1) {
            return null;
        }
        ViewServerInfo returnValue = new ViewServerInfo(server, protocol);
        synchronized (sViewServerInfo) {
            sViewServerInfo.put(device, returnValue);
        }
        return returnValue;
    }

Any idea why this is happening and how I can fix this? thx.
 
are you running the same program more than once with no changes?

and if you shut down the emulator and then run the app does it work fine?

I had a similar error
 
I had the same problem until I looked at the tutorial code and realized that I had left the line:

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

in my code instead of replacing it with the tutorial code:

super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
 
Back
Top Bottom