Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 261
Deepanshu Avatar asked Dec 04 '13 16:12

Deepanshu


People also ask

How do you fix the selection Cannot be launched and there are no recent launches Eclipse?

Click on the drop down next to the Run button, After that choose Run Configuration, shows three option, for example i choose java application add class(Name of the class of your project) in that then Click on the ok button ... Run your application :) Show activity on this post. this will help you to fix the problem.

How do I run a Java program in Eclipse?

Step 1: Open Eclipse and click File > New > Java Project. Step 2: Provide the Project Name and click on the Finish button. Step 3: In the Package Explorer (left-hand side of the window) select the project which you have created. Step 4: Right-click on the src folder, select New > Class from the submenu.

How do I compile in eclipse?

You will need to go to Project->Clean...,then build your project. This will work, even when your source code does not contain any main method to run as an executable program. The . class files will appear in the bin folder of your project, in your workspace.

What is editor does not contain a main type?

Basically, this type of Error means your Editor is not able to find the “main” method in any of your current program classes. The editor shows this error because when you want to run the project, at that time, the interpreter couldn't find the main function to start the execution of the program.


1 Answers

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.

like image 142
NigelK Avatar answered Oct 07 '22 20:10

NigelK