Java Eclipse 错误,“无法启动选择,并且最近没有启动”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20380792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:31:19  来源:igfitidea点击:

Eclipse error, "The selection cannot be launched, and there are no recent launches"

javaeclipsesdkandroid

提问by Deepanshu

I have just started Android programming so downloaded Eclipse and got started.

我刚刚开始 Android 编程,所以下载了 Eclipse 并开始使用。

Created my first project following tutorial from here: http://developer.android.com/training/basics/firstapp/creating-project.html#CommandLine

按照这里的教程创建了我的第一个项目:http: //developer.android.com/training/basics/firstapp/creating-project.html#CommandLine

And when I was on next lesson to run that application from here: http://developer.android.com/training/basics/firstapp/running-app.html

当我在下一课从这里运行该应用程序时:http: //developer.android.com/training/basics/firstapp/running-app.html

I did as they said. Connected my device via USB, enabled USB debugging too, but when I clicked Run on eclipse, got the above error.

我照他们说的做了。通过 USB 连接我的设备,也启用了 USB 调试,但是当我单击在 Eclipse 上运行时,出现上述错误。

enter image description here

在此处输入图片说明

What have I done wrong?

我做错了什么?

采纳答案by NigelK

Eclipse can't work out what you want to run and since you've not run anything before, it can't try re-running that either.

Eclipse 无法计算出您想要运行的内容,并且由于您之前没有运行过任何内容,因此它也无法尝试重新运行。

Instead of clicking the green 'run' button, click the dropdown next to it and chose Run Configurations. On the Android tab, make sure it's set to your project. In the Target tab, set the tick box and options as appropriate to target your device. Then click Run. Keep an eye on your Console tab in Eclipse - that'll let you know what's going on. Once you've got your run configuration set, you can just hit the green 'run' button next time.

不要单击绿色的“运行”按钮,而是单击它旁边的下拉菜单并选择“运行配置”。在 Android 选项卡上,确保将其设置为您的项目。在目标选项卡中,根据需要设置复选框和选项以定位您的设备。然后点击运行。注意 Eclipse 中的 Console 选项卡 - 这会让您知道发生了什么。设置好运行配置后,下次只需点击绿色的“运行”按钮即可。

Sometimes getting everything to talk to your device can be problematic to begin with. Consider using an AVD (i.e. an emulator) as alternative, at least to begin with if you have problems. You can easily create one from the menu Window -> Android Virtual Device Manager within Eclipse.

有时,让所有东西都与您的设备通话一开始可能会出现问题。考虑使用 AVD(即模拟器)作为替代方案,至少在遇到问题时开始使用。您可以从 Eclipse 中的菜单 Window -> Android Virtual Device Manager 轻松创建一个。

To view the progress of your project being installed and started on your device, check the console. It's a panel within Eclipse with the tabs Problems/Javadoc/Declaration/Console/LogCat etc. It may be minimised - check the tray in the bottom right. Or just use Window/Show View/Console from the menu to make it come to the front. There are two consoles, Android and DDMS - there is a dropdown by its icon where you can switch.

要查看在设备上安装和启动项目的进度,请检查控制台。它是 Eclipse 中的一个面板,带有问题/Javadoc/Declaration/Console/LogCat 等选项卡。它可能被最小化 - 检查右下角的托盘。或者只是使用菜单中的 Window/Show View/Console 使其出现在前面。有两个控制台,Android 和 DDMS - 其图标有一个下拉菜单,您可以在其中切换。

回答by VikramV

Follow these steps to run your application on the device connected. 1. Change directories to the root of your Android project and execute: ant debug2. Make sure the Android SDK platform-tools/directory is included in your PATHenvironment variable, then execute: adb install bin/<*your app name*>-debug.apkOn your device, locate <*your app name*>and open it.

按照以下步骤在连接的设备上运行您的应用程序。1. 将目录更改为 Android 项目的根目录并执行: ant debug2. 确保 Android SDKplatform-tools/目录包含在您的PATH环境变量中,然后执行:adb install bin/<*your app name*>-debug.apk在您的设备上,找到<*your app name*>并打开它。

Refer Running App

参考正在运行的应用程序