Лична страницата на Крум Лозев. Блог, снимки, мисли
Kik's web blog
"It's not that we gotta do what we do
It's what we know, so to me it ain't nuttin but bein true..."
-- DMX "The Rain"
Статии за 2011-03

Why am I writing this?

(Skip this part)

Well ... I lost almost a day getting (Eclipse + Android SDK + several external tools and plugins) working correctly; after getting prepared and actually started writing, Eclipse crashed when i tried to align the toolbars, when it autocompleted my code and so on; generally it was useless. My anger took over and I rm -rf ./Eclipse/ and started over. Unfortunately there is no guide dedicated on how to get console tools WITHOUT Eclipse, so I decided to share my experience.

Actually Android's SDK offers a great deal of dev tools, so you don't really need to get in trouble if you are not familiar with Eclipse (100+ Mb for an upgraded notepad... Yeah, right!). Well - all I need was a text editor + Android's emulator to test the apps against.

What i need?

JDK

http://www.google.bg/search?q=jdk

Since I am goind to develop Java applications I need the javac ofc (Smile)

In my case I already had it because of my university Java course but here is what you need to do:

Since I don't want Java files + Android's SDK to mess up my system libs I created a shitz directory called "javaDev/" where I got both JDK and Android's SDK; this is generally a good idea since: I can just cp -R javaDev/ ./*elsewhere*/ and get my projects + environment working without additional troubles; I can keep track on whats happening when updating single component (like new JDK); I can easily get rid of all this (Smile). So download and extract JDK somewhere. Later this directory will be set to JAVA_HOME in the terminal.

apache-ant

http://slackbuilds.org/repository/13.1/development/apache-ant/

I personally used slackbuilds.org to get it working, but on different distros use the best/fastest way to get it.

Android SDK

http://developer.android.com/sdk/index.html

Downloaded and extracted in a *USER* directory - same reasons again.

Configure + Start new project + debugging it

Starting the emulator

Android's SDK comes with a GUI tool that turned out to be quite useful. Start it with ./android-sdk-linux_x86/tools/android. it will configure a Virtual device profile which will be later used for the emulator. The GUI is quite simple so I wont go in details. Only thing is - remember how you call the AVD (in my case it's "my_android").

At this point you can fire up the emulator by "./android-sdk-linux_x86/tools/emulator -no-boot-anim -avd my_android" (or trough the GUI).

Creating a project

This part was the strange one but it is actually needed to get things rolling. Use the Android SDK to prepare a project directory in which you can later call ant to compile the application. Here is the command: # Assuming you are in the *shitz* directory PROJECT=MyFirstProject ./android-sdk-linux_x86/tools/android create project --package com.android.$PROJECT --activity $PROJECT --target 1 --path ./$PROJECT There is a lot of info on creating projects in the developer.android.com so I am skipping details.

So now you have a default project so you are ready to start developing against the default empty project.

How to test your application

At some point you need to see how development is going on. You have the emulator running - how to install your app on it: # Enter your project dir cd ./$PROJECT # or however you called it # if you installed JDK in user dir you need to export JAVA_HOME=*path_to*/jdk1.6.0_18/ # Set the correct path here ant install Now you can start you application on the running emulator

Now you need to be able to gather you application output. Here the adb is needed. It creates a bridge to the running emulator and enables a great deal of goodies. So collecting the debug data: ./android-sdk-linux_x86/platform-tools/adb shell logcat In this case the bridge will invoke the "shell" and start "logcat" in it. This will provide you with all you need to debug a crash or get app output.

Useful topics

I was about to list some links but since most/all of them are references to http://developer.android.com/guide/ I will only recommend you to read it carefully starting with this: http://developer.android.com/resources/tutorials/hello-world.html

[ Нагоре ] [ Няма коментари ]
Има 1 статии за този месец
Get Firefox! X Multimedia System Pidgin Instant messanger Get Slackware Valid XHTML 1.0 Transitional [Valid RSS]

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.5 Bulgaria License.
Това е лична страница. Писаното тук не е мнение на хора свързани по какъвто и да е начин с мен и не трябва да се цитира като такова!