Starting with Android
Disclaimers and ExpectationsI'm only writing this for Windows (7 to be specific) and only for the Samsung Galaxy Tab 10.1 16Gig WiFi Only Gray version (Yes 'Gray' appears to matter) with the Samsung TouchWiz updates running Android 3.2. I'm also assuming that you already have the latest Ant build tools installed and working (it's the default build tool for the projects auto-created by the SDK).
Getting the SDKGo to the Android Dev site and follow the links to download the installer. Run the installer (I installed to C:\android) and eventually get the Android SDK Manager GUI (which you can bring back by running the SDK Manager.exe from the install location). Select whatever you want in addition to an API packageyou need to have at least one API package.
Path tweaksI had to tweak my path after installing, I'm guessing because I picked a custom install dir. Just...
- Press the <Windows>+<Pause> key combo
- Select Advanced system settings on the left side
- Select Environment Variables
- Scroll down in the System variables list until you see the Variable Path
- Select it, find all occurances of android and make sure they refer to the install location you selected above
- Click OK, OK, OK
Verify that your SDK setup is correctYou'll want to run the command android sdk to open the SDK Manager so that you can verify that the SDK Path shown under the menu is the same as the install path that you selected above. Assuming your path is correct, you should be able to run the command android list targets and see the API versions installed. If any of this isn't showing the information you'd expect, you'll want to verify that the Path environment var is correct using the steps from the Path tweaks section above.
Auto-creating a new projectIf you run the command android create project you can see the options that can be provided. At the least you must provide values for the --target, --path, --package, and --activity options. The --target option specifies which API you'll be targeting. The --path option is just the directory where the new project will be created. The --package option specifies the Java package your Application's code will be placed under. The --activity option is the name of the main Activity class that will be created.
The API target, or API level, is an always increasing integermeant to provide a reliable way of referring to a specific set of functionality. You can find the number you should provide as a value by running the command android list targets (the 's' is optional). After running that command you will want to select the 'id' as the value you provide to the --target option. Based on what I selected to install from the SDK Manager, when I list the targets I see:
Available Android targets: ---------- id: 1 or "android-13" Name: Android 3.2 Type: Platform API level: 13 Revision: 1 Skins: WXGA (default) ABIs : armeabi ---------- id: 2 or "Google Inc.:Google APIs:13" Name: Google APIs Type: Add-On Vendor: Google Inc. Revision: 1 Description: Android + Google APIs Based on Android 3.2 (API level 13) Libraries: * com.android.future.usb.accessory (usb.jar) API for USB Accessories * com.google.android.maps (maps.jar) API for Google Maps Skins: WXGA (default) ABIs : armeabi
So, in the end, we'll run the command android create project --target 1 --path c:\appname --package tld.company.appname --activity AppName. There a handfull of files created and I'll only cover the few that are relevant to getting our project on a device.
Avoiding AVDsSo. An AVD is nice if you don't have a device... but they are slow as molasses compared to a device. If you have a device, use it, and avoid working with AVDs. Getting your device's USB drivers set up (if you're on Windows) can be a pain, but it's worth it. I'm only going to cover the Samsung Galaxy Tab 10.1 drivers (Specifically the 16Gig WiFi versionGray ... yes, apparently that matters).
USB DriversThe driver installer you want is called GT-p7510_USB_Driver_v1_3_2360_0-Escape.exe as of June 7th, 2011. Yeah. So. Here's the steps:
- Go to Samsung's website
- Search for 'driver' in their search form in the upper right corner
- Specifiy the Product Type (Galaxy Tab), Product SubType (WiFi Tabs), Product Model (Galaxy Tab 10.1 (Wi-Fi Only) Gray). (See, I said it appears to matter.)
- Click 'Find Download'
- Select the tab 'Software'
- Select the 'USB Driver' link (it'll show the 'full' description as: GT-p7510_USB_Driver_v1_3_2360_0-Escape USB Driver for Wireless Tab)
- Click the 'Exe' icon to the right on that same row
- Agree to disclaimer
- Run the downloaded EXE
- Agree to let it install (funny that it says it's the USB Driver for Mobile Phones...)
- Traditional black magic that might involve rebooting
Device configThe only thing that you need to modify on your device is to enable USB debugging.
- Tap the Clock in the lower right corner
- Select 'Settings', 'Applications', 'Development'
- Check the box for 'USB debugging'
Verify that your device setup is correctYou'll know you have a working driver and android sdk setup if you connect your device and it shows up when running the command adb devices (this time the 's' is not optional). When I run that command (after attaching my device) I see:
List of devices attached 43C800241209457 device
Whatever shows up will likely look different than what I see, but that something shows up is the key. I also see the option 'USB debugging connected' when I tap the clock on my device.
Getting Hello World onto the deviceYou should have the SDK and an API platform installed. You should have a shell of a project auto-created. You should have the USB driver installed. ADB should be telling you that it sees a device when you connect it.
Now, go into the project directory that was auto-created (the first directory with the build.xml file in it), and run the command ant debug install. You'll see the build process run by and eventually end up on the 'install' task where your app is uploaded to your device. On your device, select 'Apps' in the upper right corner, then find your app (if you used the command above verbatim, you'll find it under 'SomeApp'). Click the app and you'll see it open up.
Now you only have to learn the API... and write a whole bunch of code... and become an artist... and a marketing guru...