1

Firstly, I want to state that I'm a novice when it comes to Android (or Java, for that matter) so there is certainly a strong possibility I'm doing something wrong at a very basic level - please keep this in mind.

I will include basically the whole source as I have no idea where the problem is based (and before anyone suggests I try using Google, I've already spent the last couple of days doing that).

The problem occurs when I try to run or debug the app where I receive the following error message:

eclipse.buildId=M20100909-0800
java.version=1.6.0_24
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_NZ
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.java.product


Error
Fri Feb 25 15:52:44 CET 2011
No command output when running: 'am start -n com.company.android.app/com.company.android.app.Home -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' on device emulator-5554

com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:408)
at com.android.ddmlib.Device.executeShellCommand(Device.java:276)
at com.android.ide.eclipse.adt.internal.launch.ActivityLaunchAction.doLaunchAction(Unknown Source)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.launchApp(Unknown Source)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.simpleLaunch(Unknown Source)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.access$3(Unknown Source)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController$3.run(Unknown Source)

The app is a very basic thing. It has a single Activity with the following XML code in the view:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/helloAndroid" 
    android:text="" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
/>

And the following code in the Activity's *.java:

package com.company.android.app;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.widget.TextView;

public class Home extends Activity {

    TextView helloWorld;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        helloWorld = ( TextView ) findViewById( R.id.helloAndroid );
        helloWorld.setText( "Hello Android!" );
    }
}

And finally, in my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.company.android.app"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Home"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

When I run or debug the app I see the following in the console:

[2011-02-25 16:22:52 - com.company.android.app] adb is running normally.
[2011-02-25 16:22:52 - com.company.android.app] Performing com.company.android.app.Home activity launch
[2011-02-25 16:22:52 - com.company.android.app] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Android-2.3.3'
[2011-02-25 16:22:57 - com.company.android.app] Uploading com.company.android.app.apk onto device 'emulator-5554'
[2011-02-25 16:23:00 - com.company.android.app] Installing com.company.android.app.apk...
[2011-02-25 16:23:22 - com.company.android.app] Success!
[2011-02-25 16:23:23 - com.company.android.app] Starting activity com.company.android.app.Home on device emulator-5554

A little additional info:

  • The emulator opens and runs - but never gets beyond the Android splash image nor can I interact via the buttons (i.e. 'Home' does nothing).
  • The app is targeted to Android 2.1-update1.

I can't think of anything else to include.

Any ideas what might be causing this problem?

Many thanks in advance. Zac

AMadmanTriumphs
  • 4,888
  • 3
  • 28
  • 44
Zac Seth
  • 2,742
  • 5
  • 37
  • 56
  • 3
    The emulator never responding is a problem -- sometimes the emulator takes a LONG TIME (several minutes or more) to come up and be fully responsive. You should definitely get through that issue before you move forward with debugging your app. I would suggest just launching the emulator (not via your app) and making sure you can get it to come up and show the home screen, etc.; give it plenty of time. – Guy Starbuck Feb 25 '11 at 16:34
  • 1
    Not getting past the Android splash image is a big problem. Does this happen when you start the emulator via the AVD Manager? Also, can you try debugging one of the sample projects as a sanity check? – Matthew Feb 25 '11 at 16:34
  • 1
    Are you able to start the emulator by itself (without starting it via debugging your application)? It can sometimes be slow to start, i.e. 1-2 minutes depending on your system specs. – Erich Douglass Feb 25 '11 at 16:37
  • Thanks for your replies. I have the same problem with the emulator whether I open it by running the app or from the command line. My computer isn't exactly powerful but I had the emulator running for a couple of hours and it never progressed. Just tried it from the AVD Manager as well and have had the same result. Are there any good resources for resolving emulator-specific issues (aside from developer.android.com)? Would it be worth re-installing? I've tried sending an unlock command via telnet ("send event EV_KEY:KEY_MENU:1") but this seemed to have no effect either. – Zac Seth Feb 25 '11 at 17:09
  • 1
    Maybe try a clean start with the emulator? Either delete the AVD and create a new one, or start it from the AVD manager with "Wipe user data" checked and "Launch from snapshot" cleared. – erichamion Feb 25 '11 at 18:55
  • Starting it with "Wipe user data" checked and "Launch from snapshot" worked perfectly! Thanks - if you want to post your suggestion as an answer I can mark it as the correct answer (otherwise I'll just post your solution myself). Thanks! – Zac Seth Feb 28 '11 at 13:45

2 Answers2

0

I don't understand where (in eclipse) do you get the first error log.

Your code is trivially correct and, even if that is weird to me to not use any Layout around your TextView (because just a TextView is useless), runs find here…

At first, you should try to run a "from scratch" android project and check: 1. the resulting HelloWorld on the emulator; 2. check the logcat view and fnd something like "ActivityManager Displayed Activity com.yourpackage.youractivity"

If it does work, proceed step-by-step with programmatic UI definition to fi your needs.

Anyway, you should use "Log.i("MyApp","within onCreate()");" and check logcat (the logcat view is your friend) if there is any exception.

Renaud

Renaud
  • 8,783
  • 4
  • 32
  • 40
  • Thanks for your reply Renaud. As the commenters on my question suggested the problems was related to the emulator - not my app. I had tried to use Log.i("", "") but wasn't seeing any log entries because it wasn't even executing my code. The suggestion to use a layout was useful though - I didn't realise they were needed (I have a lot to learn, I think). – Zac Seth Feb 28 '11 at 13:48
0

The solution I found was provided by @erichamion in the comments to my question. I restarted the emulator via the AVD Manager with the "Wipe user data" option checked and the "Launch from snapshot" option unchecked.

I suspect that when I first loaded the emulator it was interrupted by me somehow and was left in an inoperable state. Clearing the user data and wiping the snapshot overcame that problem by loading the emulator with a fresh state.

Thanks for the help...

Zac Seth
  • 2,742
  • 5
  • 37
  • 56