I have talked to quite a few people lately about my plans. While many express a certain kind of doubt about the steps I am currently taking (most often quoting that dilbert comic), many others are curious about android and talk about programming some android “stuff” themselves. If you already know java, getting started is so easy, I thought I’d share the first few steps with you and give you some links to make it even easier!
So don’t just talk about programming android apps, do it! Follow these steps: I promise it takes less than an hour (unless you have a really slow internet connection!) and you’ll have hello world running on your device (or emulator) in no time!7+1 steps to conquer the world with your android app:
- Download the Android SDK and install it. This mostly means unpacking your download somewhere. I opted for my usual /opt/ but I am having trouble with that because I must run the manager as root now. Bonus step: you may also want to add the tools and plat-form tools folders to your path (see I have done this on a linux machine, how this part works on window – no idea).
- Download some SDKs: in your newly installed Android folder, run tools/android:
- Go to “Available Packages” and check whatever SDK Version you want to develop for.
- To find out the version that is installed on your device: Go to Settings > About Phone > System version, from now on I’ll call that ‘your version’,
- If you don’t have a device I suggest you choose 2.1 or 2.2 for now since those are the most common versions, if you want bleeding edge take 3.0 that’s just been out a few days (I was reminded last night that 3.0 is tablet only!).
- You might want to download the samples as well.
- Wait for the download to complete – should take only a couple of minutes.
- Eclipse Support: I am assuming you already have an eclipse installation? So now install die Eclipse addon, here’s the update url.
- Creating a project: Go to File > New > Android Project.
- Give your project a name and choose your target version.
- The application needs a name as well and a package. Take care with these two, if you want to publish your app that’s what the market sees. The Market is searchable by package name and the app name really is the public name as seen on your home screen and in the market.
- Last enter the API Level of your chosen SDK Version into the MIN SDK Version field.
- Hit Finish. Now you have your first skeleton project which is ready to be run in the emulator.
- First however take a look at the project: you should find the following
- a source folder named src with java a java class (an activity!)
- a source folder named gen with a generated java class (R.java, your connection to your xml files)
- a build path entry with your SDK version
- an empty assets folder
- the res folder with some xml files and icons – this is where all your UI resources will go (most UIs are mostly xml and some png files)
- the manifest for your application AndroidManifest.xml – this defines some important basics for your application, for example your activities (remember that when one of your first experiments doesn’t work). ADT also provides a nice editor for this file.
- a default.properties file
- The emulator: In Eclipse go to to Window > Android SDK and AVD Manager and create an AVD (‘Android Virtual Device’) with the New Button. Enter the following parameters:
- Name = MyTestAvd
- Target = your version of the SDK
- SD Card Size = 16 (you can also roll some dice for the number, I think the minimum is 12)
- For now leave the other options on default. (If you know your devices screen resolution you might want to use that of course, if you don’t know it exactly you can easily find out the resolution once you started programming a bit
- Run your application on the emulator: so there you’re done. Not yet? Just hit “Run As Android Application”. This should start up the emulator. You’ll have to “unlock” it just like a phone and then the app starts and prints hello world (see screenshot at the top of the article).
- Bonus Round 1: Check out the “Log Cat” view in eclipse! It shows some logging, it will also show whatever you want to log in your application.
- Bonus Round 2: How about deploying to your device? Eclipse generates a deployable artifact in the bin folder (hint: it’s the *.apk). You can just copy that on your device in a multitude of ways:
- enable your device for development and deploy with eclipse
- copy on the SD card and use an App-Installer app to install it
- download from the web
I hope this article was able to motivate a few of you to get started with your hello world. If you have any more questions please don’t hesitate to ask. I’d love to hear if any of you really did get started with android lately?
PS: I did finally publish my first app, more on that experience later