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

Deepanshu picture Deepanshu · Dec 4, 2013 · Viewed 295.1k times · Source

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

Created my first project following tutorial from here: 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

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.

enter image description here

What have I done wrong?

Answer

NigelK picture NigelK · Dec 4, 2013

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.

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.

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.

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.