Saturday, August 28, 2010

Samsung Galaxy S Android Programming with Windows 7 64 bit

I managed to get a program written on my computer running on my phone. Which might not sound much, but it was a lot more work than I thought, and I tried a lot of things that didn't work, so I thought I'd record what I did for the benefit of anyone else.

My Setup
My Steps

And now, here are the steps I followed. They might not all be necessary, but they worked.

Precursors
  1. Get the hello world app working in eclipse in the emulator as described in the link above, before going anywhere near the phone.
  2. Reboot. This was just because I gave up one evening, and started a few days later but had the side benefit of stopping the adb daemon.
  3. Get the machine to a clean state. While trying to get this to work, I had tried and failed with quite a lot of methods. These included installing other apps in the hopes of getting drivers, downloading random driver files off the internet and so on. Since I didn't trust the driver state of the computer, I restored to a system restore point when I hadn't done anything with the phone. So now we probably have no samsung drivers.
Now we are going to get the phone nicely connected to PC, pretending we are just a normal user, not worrying about being a developer.
  1. With the phone disconnected from the USB cable, under Settings, Applications, Development, turn OFF USB debugging.
  2. Under Settings, About Phone, USB Settings, change to "Ask on connection". This will give you some control.
Installing Kies to get drivers
  1. Now we want the proper Samsung drivers, and we are going to rely on Samsung Kies to do it. Download Samsung Kies from the Samsung website: http://www.samsungapps.com/about/onPc.as. Install it, and reboot if it requests. Now whenever your phone connects in whatever mode Kies will try and take over.
  2. Start up Kies manually. Connect your phone, and when it asks you choose mode choose Kies. Windows should install some drivers, then Kies should detect it and show it in the top left corner.
  3. Eject the phone from Kies, and unplug the cable.
  4. In the Kies tray menu, turn off Auto-start, and quit Kies.
Install as a USB drive to get drivers
  1. Now we want to make sure using the phone as a USB drive works.
  2. Plug the phone in. Kies shouldn't start. Choose "Mass storage" on the phone. Windows should install some more drivers. It won't show yet as a working drive.
  3. On the phone you have pull down the notification screen, which should say "USB connected".
  4. Click on this, and will give you the option to Mount as a drive. Select Mount.
  5. Check you can copy a file back and forth.
  6. Eject the USB drives from Windows and disconnect the phone.
Now you should have a nicely working phone like a normal user, and hopefully all the drivers installed you will need. If you can't get here, don't vene bother with the next steps, you've got to get the phone working first. Try uninstalling Kies and reinstalling, or uninstalling any 3rd party software for use with your phone.

Being a developer

Next we are going reveal our true identity as developers.
  1. IGNORE everything it says at http://developer.android.com/sdk/win-usb.html. Having the package provides drives for a few specific phones. Having it installed won't hurt - I've got it installed, but don't expect it to help. You've got a Samsung Galaxy S, and the package doesn't support this at all.
  2. On the phone, with it disconnected, under Settings, Applications, Development, turn ON USB debugging.
  3. Connect the phone. Windows says it is installing device driver software - a good sign. However, on my machine it then says Device driver software was not successfully installed - a bad sign! But DON'T PANIC.
  4. Go to Control Panel, Devices, Hardward and Sound. The phone should appear as SAMSUNG_Android with a list of all the things it can be. This is good. It appears Windows was lying.
  5. Now as it says on http://developer.android.com/guide/developing/device.html#setting-up you can check to see if it is connected with adb.
  6. Start a command prompt (run cmd.exe from the Start menu).
  7. Change to wherever you installed the Android SDK, and into the tools directory.
  8. Run "adb devices" at the command prompt. My machine said:
D:\Program Files\android-sdk-windows\tools>adb devices
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
900012345678 device

Hooray - we are all connected and working. Now just follow the instructions on: http://developer.android.com/guide/developing/eclipse-adt.html#RunningOnDevice - just use Run on the eclipse menu and your device should appear, and eclipse will install and run it on your phone. Result!

3 comments:

Unknown said...

Thanks for the post. I was having trouble getting the Galaxy connecting for development as well.

Unknown said...

Excellent post. I used your suggestions on my 32bit WinXP PC. I additionally did the following:
- restart PC (I think you are right about the Android processes that are still running),
- download the "uninstall kies" file from samsung
- uninstall kies.
- then followed your instructions exactly.

Developers definitely need to follow the developer.android.com link you provided - and make javascript:void(0)sure the change their run configuration to use "manual" device selection.

JP said...

Thanks a bunch for the post. Was having the same issue and you got me over the hump.