简体   繁体   中英

Eclipse Helios Android emulator how to run sample project

Hi I have installed eclipse helios with android emulation like its written http://www.futuredesktop.org/developing_android_apps_on_ubuntu.html but after running application

package com.example.android.apis;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class ApiDemos extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");
        setContentView(tv);
    }
}

I only see this screen 在此输入图像描述 How can I run this simple project ??

Edit: Problem was that package name was always this same, when I changed it, it works fine.

Ok, after you posted what your eclipse is saying there are two routes you can take, either make a new project or uninstall the existing. I will cover both.

Uninstalling: Exactly what it says. Open up a terminal. If you are on windows do

C:\\Program Files\\Android\\android-sdk\\platform-tools\\adb uninstall com.example.android.apis As needed (either because you installed it elsewhere or you are on Linux/Mac), substitute C:\\Program File\\Android for the Android home folder. You should know where it is since you declared it. If you are unsure, in Eclipse do Window -> Preferences -> Android and look at where the android sdk is.

Making a new project:

In eclipse File -> New -> Android Project . Follow the steps to creating a new android project. There are two things you want to note here: the Create Activity and Package name . Your package name something like com.example for now (or whatever you want it to be). It should not be the same as com.example.android.apis . Then just copy and paste the above code into your new Android class. You might need to change the class name from ApiDemos to your new Activity name.

Package Explorer中 ,右键单击项目文件夹并选择Run As

I think you didn't start the app but the emulator only, by using the menu "Windows/Android and SDK manager/start [applied to a virtual device]" of Eclipse.

When you start your app, the console output of Eclipse shoud be saying (replace 00-sandbox by the name of your app):

[2011-08-30 13:26:16 - 00-sandbox] Uploading 00-sandbox.apk onto device 'emulator-5554'
[2011-08-30 13:26:16 - 00-sandbox] Installing 00-sandbox.apk...
[2011-08-30 13:26:19 - 00-sandbox] Success!
[2011-08-30 13:26:19 - 00-sandbox] Starting activity org.shlublu.android.sandbox.Main on device emulator-5554
[2011-08-30 13:26:22 - 00-sandbox] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.shlublu.android.sandbox/.Main }

If this is not the case, this means the app was not uploaded or not started on the emulator, or neither of them. You must then press "ctrl+f11" to run the application. Eclipse will ask you whether this is an Android app, a Java app or anything else: chose "Android Application".

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