Development in NetBeans

searchcoilSoftware and s/w Development

Aug 15, 2012 (5 years and 3 months ago)

296 views

Android Development

Using
Windows and
NetBeans

6.9


1.

Download the Android SDK, installer_r11
-
windows.exe, from:


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

2.

Install
the SDK. On the second dialog,

it may come up saying it can’t find the JDK or it
is the wrong version. So you may have to “help” it find the latest JDK (e.g., C:
\
Program
Files
\
Java
\
jdk1.6.0_20). You can default on everything else, it doesn’t take long to
install.


3.

Start the
Android
SDK Manager
. If it doesn’t start,
l
ook at Control Panel
-
> System
Properties
-
> Advanced tab
-
> Environment Variables
-
> Path. Make sure the path to the
Java SDK bin (e.g.,
C:
\
Pro
gram Files
\
Java
\
jdk1.6.0_20
\
bin) is before that for
windows
\
system32

and th
at for any other path that may have a version of java.exe in it.

4.

Install all the packages from Android SDK Manager
. This can take awhile (
hour or so).

5.

Install the nbandroid plugin for NetBeans:

a.

Start NetBeans

b.

Tools
-
> Plugins
-
> Settings Tab, Click Add

c.

In Dialog, Leave “Check for updates …” Check. Put Name:
Android Plugin

URL:
http://kenai.com/downloads/nbandroid/updatecenter/updates.xml

d.

Go to the Available Plugins tab, clic
k on
checkbox for Android and click Install

e.

Proceed through the installation


it will say it is not trusted, that’s OK.

6.

Tell Net
B
eans where the
Android SDK

is:

a.

Tools
-
> Options
-
> Miscellaneous, choose Android Tab, Browse to where you
installed it, e.g.,
C:
\
Program Files
\
Android
\
android
-
sdk

and click OK

7.

Start a new Android Project: File
-
> New Project, Choose Android and Android Project

a.

Pick Na
me, Location as you do for Java programs

b.

Leave

Set as Main Project


checked.

c.

Choose an Activity Name (name
will s
how as
App

Activity when installed
)

d.

Choose a Package Name

(like Java packages, use dotted name: xxx.yyy

e.

Choose an Android Platform.
Try Android 2.2.
It is easy to change it and rebuild
later.

8.

Hello World App

a.

Open the Java Source Code for your Activity

b.

A
dd the import:
import android.widget.TextView;

c.

Modify the OnCreate method and replace the setContentView line with:

TextView tv = new TextView(this);

tv.setText("Hello

World!

");

setContentView(tv);

d.

Build it: Run
-
> Build Main Project

9.

Creat
e a Simulator

(Android Virtual Device)

a.

Start the Android SDK Manager

b.

Choose Virtual Devices and click New

c.

Pick a Name, like MyDevice_2_2 and a Target
, like Android 2.2.

d.

Default on rest and click “Create AVD”

10.

Run your program on the virtual device

a.

From Netb
eans, select Run
-
> Run Main Project

b.

If you have more than one AVD, it will ask you to choose one

c.

It may take
awhile (maybe a few minutes)
, but the AVD should eventually come
up and be ready for use.

d.

Run the App as you would from the real device

11.

Copying an
d r
un
ning

your program on the real device
, no debugging

a.

I was able to do this on the Archos 43. I could not do it on the Xoom. In
particular, Xoom has no Windows Explorer equivalent. I read some web postings
that indicate there
is

an App you could get t
o
do

something like Explorer, but not
sure if it would let you browse to a file and install it.

So I was able to go through
step f for the Xoom, but could not do step g.

b.

On the Device, go to Settings
-
> Applications
-
>Development and make sure
USB debugg
ing in NOT checked

c.

Connect your device to your computer via USB. It should mount like a drive.

d.

On your PC, browse to your NetBeans project folder,
then to its bin folder

e.

Copy the .APK file (NOT the unaligned one) to somewhere on the Android. You
can make

a new folder like Temp if you want.

f.

Disconnect the USB

g.

Browse on the device to where you put it the APK file, tap it, and install it.

h.

Then Open it to run it.


12.

Debugging your program using NetBeans on the real device

a.

I was able to do this for the Xoom but
not the Archos 43. There is a special
firmware version for development on the Archos at the following, but I did not try
it

and not sure it would even work for the Archos 43
:

http://www.archos.com/support/support_tech/updates.html?lang=en

b.

Download any special Windows drivers
to allow a debugging connection. For the
Xoom, download

and install

the Motorola USB Driver 5.0 from


http://www.motorola.com/Support/US
-
EN/Support
-
Homepage/Software_and_Drivers/USB
-
and
-
PC
-
Charging
-
Drivers

c.

On the Device, go to
Settings
-
> Applications and enable Unknown sources. Go
to
Se
ttings
-
> Applications
-
>Development and check USB debugging
. For the
Xoom, Settings is under “Device Administration”.

See
http://developer.android.com/guide/developing/device.html

d.

Connect the Xoom via USB to the PC. When the “Found New Hardware” wizard

comes up,
ignore it for now. From the start menu on the PC,
select
All Programs
-
> Motorola
-
> Motorola Drivers
-
> Motorola Driver Installer. Select Update
Drivers. When it gets done, cancel out of the “Found New Hardware” wizard.
You can check if thi
s works by using a CMD prompt, going to
C:
\
Program
Files
\
And
roid
\
android
-
sdk
\
platform
-
tools and running

adb devices

. The device
should appear (hex number and the word device).

Note that every time you
connect after this, it will probably come up with t
he “Found New Hardware”
wizard. Just cancel out. Not sure how to get rid of this. I assume it wants to also
install another driver. As long as “adb devices” shows this device, it should be
okay.

e.

Go to NetBeans and run the project. The App should appea
r on the Xoom.


Note: We probably want to get the files from above and put them at:

S:
\
Academic
\
CSSE|Software