How to get started with Android and Netbeans

21 02 2009

The Android development environment currently comes as a SDK 1.1 and can be used as a Eclipse plugin (ADT). The installation is easy and well documented, but I still summarize the steps to get it running in Netbeans and highlights some of the glitches I experienced until it was running.

  1. Download the SDK from developer.android.com (link)
  2. Unpack the zip file to your harddisk (DONT use paths with spaces !).
  3. Read the installation guidelines (link). Skip the Eclipse part, but look at the path settings.
  4. Follow the instructions for the Netbeans plugin installation at the Kenai project (link)
  5. Follow the quickstart guide to configure and setup Netbeans and start your first “HelloWorld” project.
    New Android Project

    New Android Project

    package org.me.hellodroid;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class MainActivity extends Activity {
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
    
            setContentView(R.layout.main);
            TextView tv = new TextView(this);
            tv.setText("Hello, Android");
            setContentView(tv);
        }
    }
    

    Here my problems started..

  6. Compile the project
    Problem 1:  Cannot compile
    Unable to access jarfile ..\framework\apkbuilder.jar
    a) Check there are no spaces in your path to the jarfiles in the SDK
    b) Change the apkbuilder.bat file in the tools folder of the SDK

    set jarfile=apkbuilder.jar
    set frameworkdir=
    set libdir=
    

    to

    set jarfile=apkbuilder.jar
    set frameworkdir={your_path}\android-sdk-windows-1.1_r1\tools\lib\
    set libdir={your_path}\android-sdk-windows-1.1_r1\tools\lib\
    
  7. Run the project (in the emulator)
    Problem 2:  The emulator starts up but the application (filename.apk) is not executed (not uploaded in the first place), even the emulator is started by Netbeans.

    Deleting: V:\VAR_Projects\HelloDroid\dist\HelloDroid.apk_
    jar:
    Result: -1
    

    Either you leave the emulator running after the first failed attempt or start the emulator manually from the tools folder.

    Android Emulator

    Android Emulator

Thats about all I can add at the moment. Now walk through the manuals and tutorials to get some real applications running and waiting for the device to arrive here for the real thing.


Actions

Information

3 responses

15 03 2009
Kevin

I have followed the tutorial from Netbeans Wiki – Android and I have also found your website. We seem to be sitting in the same boat. Did you figure out any solution yet?
If you have, I would love if you could post it up here, or email me.

22 10 2009
quanghoa

please help me!
Can I have a project hello world with netbean android project?
please send to me>>quanghoahcm@gmail.com
thanks very much1

10 12 2009
Rod

Hi, mine works fine from the start so never had this problem bu…

I am new at this and from what I have read on the net generally…
an AVD such as the one shown above must be higher in ‘level’ than the code or software that runs on it.

also, the directory paths must not contain spaces.

I downloaded and installed this plugin here.
sdk-windows\add-ons\google_apis-6_r01

when choosing a platform…from tools java platform – java platform manager
I chose the android + google apis rather than the standard android platform

perhaps this may work.

and the avd I chose was android 2.0.1 avi level 6 which was the highest as at 10/12/09 hope this helps…but just info on what my setup is rather than a diagnosis

Leave a comment