The official android webpage suggests that Eclipse is the best tool for devloping. I tried really hard to set it up, but after 2 days, 6 IRC channels and many differen config switches tested I gave up. PermGen out of memory error finally won with my patience. Looks like my problems were caused by java virtual machine I tried to use, but it makes no difference at all - Eclipse was unusable. I decided to got the CLI way and I'm not dissapointed.
A few words of explanation: I'll show how to create a simple "Hello World" app using just one console (or terminal window), but it's much more convinient to use 2 or 3 of them to avoid changing directory all the time.
Three steps to my first application
1. Go to "tools" directory in android-sdk:
przemo@pldmachine ~$ cd ~/android/sdk/tools/
and type (in one line):
przemo@pldmachine$ ./android create project --target android-8 --name Test --path /home/users/przemo/workspace/Test --activity TestActivity --package com.android.test
Created project directory: /home/users/przemo/workspace/Test
Created directory /home/users/przemo/workspace/Test/src/com/android/test
Added file /home/users/przemo/workspace/Test/src/com/android/test/TestActivity.java
Created directory /home/users/przemo/workspace/Test/res
Created directory /home/users/przemo/workspace/Test/bin
Created directory /home/users/przemo/workspace/Test/libs
Created directory /home/users/przemo/workspace/Test/res/values
Added file /home/users/przemo/workspace/Test/res/values/strings.xml
Created directory /home/users/przemo/workspace/Test/res/layout
Added file /home/users/przemo/workspace/Test/res/layout/main.xml
Created directory /home/users/przemo/workspace/Test/res/drawable-hdpi
Created directory /home/users/przemo/workspace/Test/res/drawable-mdpi
Created directory /home/users/przemo/workspace/Test/res/drawable-ldpi
Added file /home/users/przemo/workspace/Test/AndroidManifest.xml
Added file /home/users/przemo/workspace/Test/build.xml
Added file /home/users/przemo/workspace/Test/proguard.cfg
As you can see "android" did all the boring job of creating app skeleton for us.
2. Go to the application directory and compile it.
przemo@pldmachine$ cd ~/workspace/Test/
przemo@pldmachine$ ant debug
[removed compile output]
echo Running zip align on final apk...
echo Debug Package: /home/users/przemo/workspace/Test/bin/Test-debug.apk
Total time: 4 seconds
Those are only last few lines of a succesful build. Now we're ready to install the app3. Go to "platform-tools" and upload the app to phone:
przemo@pldmachine$ cd ~/android/sdk/platform-tools/
przemo@pldmachine$ ./adb -d install /home/users/przemo/workspace/Test/bin/Test-debug.apk
*daemon not running. starting it now on port 5037 *
*daemon started successfully *
233 KB/s (13223 bytes in 0.055s) pkg: /data/local/tmp/Test-debug.apk Success
Now you should see a new application named TestActivity in your phone. It doesn't do anything usefull, but that's my first android app!