jueves, 11 de febrero de 2010

Meeting the code

When I enter in the android tutorial page, I decided to start in a medium - high level, I dont want the crappy "hello world" tutorial, I need something more interesting to know about android... so... chose this tutorial. The Notepad tutorial gives enough comprenhension about the language.

You have to create a new proyect, charge the donwloaded code and start playing... the more common fail is in the variable declaration. It seems like the file R.java is a variable file declaration. Usually R.java went unfilled in all android-page tutorials, so for the begginers (like me) you have to know two things:

R.java is an auto-generated file and the header says "This class was automatically generated by the aapt tool from the resource data it found. It should not be modified by hand." This is probably ok if you starts a proyect from zero but we have a coupple of files and an empty R.java class. We need to filled it by hand. Dont worry about this, if you commit a mistake Netbeans should fix it.

4 example:

package com.android.demo.notepad3;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int body=0x7f050001;
public static final int confirm=0x7f050002;
public static final int text1=0x7f050003;
public static final int title=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int note_edit=0x7f030001;
public static final int notes_list=0x7f030002;
public static final int notes_row=0x7f030003;
}
public static final class string {
public static final int app_name=0x7f040000;
public static final int body=0x7f040005;
public static final int confirm=0x7f040006;
public static final int edit_note=0x7f040007;
public static final int menu_delete=0x7f040003;
public static final int menu_insert=0x7f040002;
public static final int no_notes=0x7f040001;
public static final int title=0x7f040004;
}
}

It looks ok after modify the R.java and it runs well :)

This are the results.. i dont know why i see chinese words in the predictive dictionary :(



Cheers!

domingo, 7 de febrero de 2010

Now we can start!!!

Yeah, we can start!!

But first we have to create a AVD (Android Virtual Device).. so we are going to open another time the SDK Setup in our android SDK folder... them we go to Virtual Devices and we create one.

Later we need a new Android proyect on Netbeans:

1.- Create a new proyect on Netbeans selecting Android.

2.- Open our SDK Setup, go to devices and Start one of the created AVD's.

3.- Wait till the AVD starts... it's takes a while :(

4.- Run the proyect on Netbeans.. selecting the running AVD.

5.- Enjoy your creation.

Before start!!

1 .- First we get NetBeans, JDK and android SDK (versions 6.5+, 1.6+ and 2.0+ respectively).

2 .- Install JDK and Netbeans, then we double click the icon for android (SDK Setup) inside the folder of android, that is for local instalr repositories.

3 .- If you have Win 7 will have to go to settings and check the option "Force" since Win 7 gives problems when using SSL.

4 .- Install all the packages (it takes a while).

5 .- Open Netbeans and go to tools / plugins / settings / add, once there you write: http://kenai.com/downloads/nbandroid/updates.xml. With the name that we want and we accept.

6 .- Open tools / platforms java / add platform ... select the option of google and locate the folder where you have the repositories of the android SDK.