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

314,671

Solution 1

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.

Solution 2

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

Refer Running App

Share:
314,671
Deepanshu
Author by

Deepanshu

Updated on December 05, 2020

Comments

  • Deepanshu
    Deepanshu over 3 years

    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?

  • Deepanshu
    Deepanshu over 10 years
    it worked. I choosed my device which was coming under "Choose a running android device" named as "emulator-5554..i selected it and pressed ok. Then nothing happened. Where does the console tab located?
  • Deepanshu
    Deepanshu over 10 years
    You are explaining me in command line mode but i am using eclipse to run it. Have already followed the steps from the link you posted. Even i have posted this link above in my question.
  • NigelK
    NigelK over 10 years
    Please see my edit above.
  • VikramV
    VikramV over 10 years
    You can open the console tab in Eclipse by going to Window(tab)->Show View->Console
  • VikramV
    VikramV over 10 years
    Your posted first link states that you created your application through command line. Hence my answer. Else @NigelK's answer should do
  • Deepanshu
    Deepanshu over 10 years
    This is what console showing after i pressed run. [2013-12-04 23:01:16 - abc] Android Launch! [2013-12-04 23:01:16 - abc] adb is running normally. [2013-12-04 23:01:16 - abc] Performing com.example.abc.MainActivity activity launch [2013-12-04 23:01:16 - abc] Automatic Target Mode: Unable to detect device compatibility. Please select a target device. [2013-12-04 23:01:19 - abc] Application already deployed. No need to reinstall." Continue in next comment
  • Deepanshu
    Deepanshu over 10 years
    "[2013-12-04 23:01:19 - abc] Starting activity com.example.abc.MainActivity on device emulator-5554 [2013-12-04 23:01:20 - abc] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.abc/.MainActivity }"
  • Deepanshu
    Deepanshu over 10 years
    Sorry didn't noticed that i pasted the command line link. My bad.
  • NigelK
    NigelK over 10 years
    Well it says the Application is deployed and when you see 'Starting: Intent' that means your app has been launched on the device. Whether it has then crashed or not is another matter. If you don't see what you expect on the device, check the LogCat for errors (it's next to the console tab). We need to stay on topic here and I think this specific question has been answered (if you found my answer useful, please accept it but it's up to you). If you now have errors in your code that you can't resolve, please raise a new question. Thx.
  • Deepanshu
    Deepanshu over 10 years
    will ask a new question when will start all this from starting.