Android and NetBeans

Hey guys I’m writing this post after few weeks. This time I thought of writing a post about Android. I bought a HTC Hero, the first HTC android phone with the Sense UI . Since the day I bought the phone I wanted to write an app for the phone, but with work didn’t get much time to do that. Finally I found some time to kill, so as a result of that I’m writing this post.

First I wrote my Hello World app using Eclipse. Though it’s a powerful IDE I don’t like the idea of using Eclipse. Therefore I looked for a plugin to NetBeans to develop my first Android app. Among the first few search results I found this article How to setup Netbeans for Android development and it worked the magic. Even though the above mentioned post was written for NetBeans 6.5 it works for NetBeans 6.8 too.

Note: you have to install Android SDK to start. Follow this link to install the SDK Installing the SDK

Ok then lets start developing our first android app; to start work first you have to install NetBeans and have to install the Android plugin by following the above link.
Open NetBeans File -> New Project and you’ll get the screen below select Android as the category and Android Application as the Project and then click next.

New Project

And the next part is the Name and Location window its as same as a usual NetBeans project therefore I’m not gonna explain that to you!

Name and Location

OK now lets take a look at the first code this is really simple, the below image is the class which you have to edit.

Java class

you have to add these lines of code which is demonstrated on the following image

TextView tv = new TextView(this);
tv.setText(“Hello Android”);
Button bt = new Button(this);
bt.setText(“GO”);
setContentView(bt);

Finished code

and then you have to hit the run button and it will start the Android emulator

Running App

Try more and enjoy
bye for now
:D

Note: This link has more and further details on android development

~~ Rusiru Boteju ~~

About these ads

About Rusiru Boteju
A peculiar or otherwise odd person, especially one who is perceived to be overly obsessed with one or more things including those of intellectuality, computers, technology, etc.

14 Responses to Android and NetBeans

  1. Tom says:

    After installing the nbandroid plugin on both 6.8 and 6.9 I do not see the same project page you mention above . I am talking about the second image you have, were user selects project location and so on.
    I am trying to uninstall the plugin and reinstall it, however I don’t see the plugin listed under the plugin tab .
    I do see an Andrpid project category under File -> NewProjects though.

    • Did you follow this link ” How to setup Netbeans for Android development ” to install the plugin? (hope you followed it). And does it mean you get the project selection window(first image i have given) where the user can select the project he wants if so you should be able to proceed. I have tried this on netbeans 6.8 in ubuntu 10.04 and it worked fine for me did you download android development kit follow this link tell me what happens :)

  2. raj says:

    hello frnd, i got such type of error in netbeans , when i run the above application

    init:
    deps-jar:
    Compiling 2 source files to C:\Documents and Settings\user\My Documents\NetBeansProjects\HelloAndroid\build\classes
    compile:
    Created dir: C:\Documents and Settings\user\My Documents\NetBeansProjects\HelloAndroid\dist
    =C:\Documents was unexpected at this time.
    C:\Documents and Settings\user\My Documents\NetBeansProjects\HelloAndroid\nbproject\build-impl.xml:411: exec returned: 255
    BUILD FAILED (total time: 0 seconds)

    plz help me
    what to do now?

  3. Cabeto41 says:

    Raj you get the project in a folder without spaces in the name

  4. Android says:

    Fine app for android thanks for the tip I am already experimenting in my android and perfect
    a work in very nice.

  5. HARIHARAN says:

    Emulator is running on android 3.0 specifiction …
    But the MainActivity would not run

    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\hcl-cdc\My Documents\NetBeansProjects\compass\build\classes
    compile:
    =C:\Documents was unexpected at this time.
    Result: 255

    THIS TOOL IS DEPRECATED. See –help for more information.

    Deleting: C:\Documents and Settings\hcl-cdc\My Documents\NetBeansProjects\compass\dist\compass.apk_
    jar:
    pkg: /data/local/tmp/compass.apk
    Failure [INSTALL_FAILED_DEXOPT]
    69 KB/s (3325 bytes in 0.046s)
    About to start org.me.compass/org.me.compass.MainActivity
    Starting: Intent { cmp=org.me.compass/.MainActivity }
    Error type 3
    Error: Activity class {org.me.compass/org.me.compass.MainActivity} does not exist.
    run:
    BUILD SUCCESSFUL (total time: 9 seconds)

  6. HARIHARAN says:

    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\hcl-cdc\My Documents\NetBeansProjects\compass\build\classes
    compile:
    =C:\Documents was unexpected at this time.
    Result: 255

    THIS TOOL IS DEPRECATED. See –help for more information.

    Deleting: C:\Documents and Settings\hcl-cdc\My Documents\NetBeansProjects\compass\dist\compass.apk_
    jar:
    Can’t dispatch DDM chunk 46454154: no handler defined
    Can’t dispatch DDM chunk 4d505251: no handler defined
    pkg: /data/local/tmp/compass.apk
    Failure [INSTALL_FAILED_DEXOPT]
    3 KB/s (3325 bytes in 1.000s)
    About to start org.me.compass/org.me.compass.MainActivity
    Starting: Intent { comp={org.me.compass/org.me.compass.MainActivity} }
    Error type 3
    Error: Activity class {org.me.compass/org.me.compass.MainActivity} does not exist.
    run:
    BUILD SUCCESSFUL (total time: 9 seconds)

  7. Nakul aggarwal says:

    Sir,
    i m trying to learn android with internet but i have a problem in android with eclipse.i install all the stuff which we need…but when i create AVD then it becomes ok but when i launch that avd then a black window is open and after some seconds its hang…and not responding….what should i do and i also want to know that is netbeans 6.1 supports android

    • Hi Nakul,

      Eclipse is the best IDE to develop android applications. The netbeans approach I have given here is a bit out dated.
      What is the program you ran at first by using Eclipse is it just a hello world or some thing else? Usually the instructions provided by the Android development community on Eclipse are accurate I personally use those to do my work and i had no trouble with the AVDs. Can you please explain what happened in detail then i can help you :)

      I personally recommend Eclipse to develop android applications

      Rusiru

  8. roopa says:

    while running android project in netbeans it is showing no devices found.pls help me

  9. Karan Vinayak says:

    hey, i have netbeans 6.9 but i don’t noe how to add an android plugin(whenever i start a new project , the android option doesn’t show up) plz hlp!!! i wld be grtful to u!! thnx!!

  10. Pingback: Useful resources for developing Android apps | How To Develop Android Apps NOW

  11. Halra says:

    thank youuu,
    and please give tutorial about Install Android on Hyper-V.
    .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: