39

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Deepanshu
  • 595
  • 2
  • 5
  • 11

2 Answers2

35

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.

NigelK
  • 8,255
  • 2
  • 30
  • 28
  • 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 Dec 04 '13 at 17:14
  • Please see my edit above. – NigelK Dec 04 '13 at 17:25
  • You can open the console tab in Eclipse by going to Window(tab)->Show View->Console – VikramV Dec 04 '13 at 17:26
  • 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 Dec 04 '13 at 17:33
  • "[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 Dec 04 '13 at 17:34
  • 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. – NigelK Dec 04 '13 at 17:47
  • will ask a new question when will start all this from starting. – Deepanshu Dec 04 '13 at 17:59
1

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

VikramV
  • 1,111
  • 2
  • 13
  • 31
  • 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. – Deepanshu Dec 04 '13 at 17:19
  • 1
    Your posted first link states that you created your application through command line. Hence my answer. Else @NigelK's answer should do – VikramV Dec 04 '13 at 17:27
  • Sorry didn't noticed that i pasted the command line link. My bad. – Deepanshu Dec 04 '13 at 17:34