简体   繁体   中英

Android App Won't Display in Emulator

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 (ie '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

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

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM