简体   繁体   English

Eclipse Helios Android模拟器如何运行示例项目

[英]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 嗨我已经安装了eclipse helios和Android模拟,就像它编写的http://www.futuredesktop.org/developing_android_apps_on_ubuntu.html但是在运行应用程序之后

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. 好的,在您发布了您的eclipse所说的内容之后,您可以选择两条路线,或者创建一个新项目或者卸载现有项目。 I will cover both. 我会介绍两者。

Uninstalling: Exactly what it says. 卸载:正是它所说的。 Open up a terminal. 打开一个终端。 If you are on windows do 如果你在Windows上做

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. C:\\Program Files\\Android\\android-sdk\\platform-tools\\adb uninstall com.example.android.apis根据需要(因为你在其他地方安装它或者你在Linux / Mac上),替换C:\\ Program File \\ Android为Android主文件夹。 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. 如果您不确定,请在Eclipse中执行Window -> Preferences -> Android并查看android sdk的位置。

Making a new project: 制作一个新项目:

In eclipse File -> New -> Android Project . 在eclipse File -> New -> Android Project Follow the steps to creating a new android project. 按照步骤创建一个新的android项目。 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). 您的包名称现在就像com.example (或者您想要的任何内容)。 It should not be the same as com.example.android.apis . 它应该与com.example.android.apis Then just copy and paste the above code into your new Android class. 然后将上述代码复制并粘贴到新的Android类中。 You might need to change the class name from ApiDemos to your new Activity name. 您可能需要将类名从ApiDemos为新的活动名称。

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. 我认为你没有使用Eclipse的Windows / Android和SDK管理器/启动[应用于虚拟设备]菜单启动应用程序而只启动模拟器。

When you start your app, the console output of Eclipse shoud be saying (replace 00-sandbox by the name of your app): 当您启动应用程序时,Eclipse的控制台输出应该说(用您的应用程序名称替换00-sandbox ):

[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. 然后必须按“ctrl + f11”才能运行该应用程序。 Eclipse will ask you whether this is an Android app, a Java app or anything else: chose "Android Application". Eclipse将询问您这是Android应用程序,Java应用程序还是其他任何东西:选择“Android应用程序”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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