Sample Android application using Netbeans on UBUNTU
Step 1. Download Android SDK from
http://developer.android.com/sdk/1.1_r1/index.html
Unzip distribution.
Step 2. Setting Netbeans plugin for Android :
You can get details installing plugin for Android at
http://kenai.com/projects/nbandroid/pages/Install
Step 3.
Netbeans menu
Tools -- Java Platform
Click Add Platform button
Select Google Android Open Handheld platform.
Set Android SDK directory as Platform folder. (downloaded and unzipped in step 1)
Click next and set name as "Android".
Click finish.
Step 4. Create new Android Project
File -- Project --
Android -- Android Application
Set project Name as HelloAndroid for example.
click finish
Step 5.
Open Source packages
org.me.helloandroid.MainActivity.java file.
there is oncreate method as follows
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ToDo add your GUI initialization code here
}
Change it by adding few lines of code to display "Hello Android".
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ToDo add your GUI initialization code here
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
Step 6.
Run Application.
You will get "Hello Android" text on Android Emulator screen.
If You get Following Exception while running application :
trouble processing:
invalid constant pool index 0000
...while parsing attributes[1]
...while parsing Code attribute at offset 0000013e
...while parsing attributes[0]
...while parsing methods[0]
...while parsing org/me/helloandroid/R$layout.class
...while processing org/me/helloandroid/R$layout.class
Check java -version on console and set it as java-6
Here are steps how to set this:
on console window type : sudo update-alternatives --config java
It will give installed versions and option to set java version.
If java 6 is not in list use following link to install and set as default version
https://help.ubuntu.com/community/Java
1 comment:
For details regarding installation of android in netbeans check the following link
www.problemsolvers2012.blogspot.com
Post a Comment