[英]Eclipse Helios Android emulator how to run sample project
嗨我已经安装了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);
}
}
我只看到这个屏幕 我该如何运行这个简单的项目?
编辑:问题是包名称始终相同,当我更改它时,它工作正常。
好的,在您发布了您的eclipse所说的内容之后,您可以选择两条路线,或者创建一个新项目或者卸载现有项目。 我会介绍两者。
卸载:正是它所说的。 打开一个终端。 如果你在Windows上做
C:\\Program Files\\Android\\android-sdk\\platform-tools\\adb uninstall com.example.android.apis
根据需要(因为你在其他地方安装它或者你在Linux / Mac上),替换C:\\ Program File \\ Android为Android主文件夹。 你应该知道你宣布它的位置。 如果您不确定,请在Eclipse中执行Window -> Preferences -> Android
并查看android sdk的位置。
制作一个新项目:
在eclipse File -> New -> Android Project
。 按照步骤创建一个新的android项目。 您需要在此处注意两件事: 创建活动和包名称 。 您的包名称现在就像com.example
(或者您想要的任何内容)。 它应该与com.example.android.apis
。 然后将上述代码复制并粘贴到新的Android类中。 您可能需要将类名从ApiDemos
为新的活动名称。
在Package Explorer中 ,右键单击项目文件夹并选择Run As
我认为你没有使用Eclipse的Windows / Android和SDK管理器/启动[应用于虚拟设备]菜单启动应用程序而只启动模拟器。
当您启动应用程序时,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 }
如果不是这种情况,则表示应用程序未上传或未在模拟器上启动,或者两者都未启动。 然后必须按“ctrl + f11”才能运行该应用程序。 Eclipse将询问您这是Android应用程序,Java应用程序还是其他任何东西:选择“Android应用程序”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.