0% found this document useful (0 votes)
27 views

How to get started with Android and Netbeans

Uploaded by

netflixmaddies
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

How to get started with Android and Netbeans

Uploaded by

netflixmaddies
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

How to get started with Android

and Netbeans
Filed under: Android,HowTo,netbeans — devdude @ 7:57 pm
Tags: Android, netbeans, plugin
Update 2011-04-08: The plugin has improved. Now it is just
a matter of installing the plugin, creating an Android platform
and create a new app. (Link)Below information is outdated !

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
6. 7. package
org.me.hellodroi
d;
8.
9. 10.

11.
12. 13. import
android.app.Activi
ty;
14.
15. 16. import
android.os.Bund
le;
17.
18. 19. import
android.widget.TextVi
ew;
20.
21. 22.

23.
24. 25. public class MainActivity
extends Activity {
26.
27. 28.

29.
30. 31. /** Called when the activity is first
created. */
32.
33. 34. @
O
v
e
r
r
i
d
e
35.
36. 37. public void
onCreate(Bundle icicle) {
38.
39. 40. super.onCreat
e(icicle);
41.
42. 43.

44.
45. 46. setContentView(R.lay
out.main);
47.
48. 49. TextView tv = new
TextView(this);
50.
51. 52. tv.setText("Hello,
Android");
53.
54. 55. setContent
View(tv);
56.
57. 58.
}
59.
60. 61.
}
62. Here my problems started..
63. Compile the projectProblem 1: Cannot compileUnable to
access jarfile ..\framework\apkbuilder.jara) Check there
are no spaces in your path to the jarfiles in the SDKb)
Change the apkbuilder.bat file in the tools folder of the
SDK
64. 65. set
jarfile=apkbuild
er.jar
66.
67. 68. set
framewor
kdir=
69.
70. 71. se
t
li
bd
ir
=
72. to
73. 74. set
jarfile=apkbuild
er.jar
75.
76. 77. set frameworkdir={your_path}\android-sdk-windows-
1.1_r1\tools\lib\
78.
79. 80. set libdir={your_path}\android-sdk-windows-
1.1_r1\tools\lib\
81.
82. 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.
83. 84. Deleting: V:\VAR_Projects\HelloDroid\dist\
HelloDroid.apk_
85.
86. 87.
ja

88.
89. 90. Re
su
lt
:
-
1
91. Either you leave the emulator running after the first failed
attempt or start the emulator manually from the tools
folder.
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.

How to install Android plugin version


1.x into NetBeans

Check our blog for updates.

Install using autoupdate center

The simplest way how to install nbandroid modules and keep them
updated is to register an autoupdate center in your NetBeans
installation. Address of this update center is
http://kenai.com/projects/nbandroid/downloads/download/updatecenter/
updates.xml. To register this update center, simply go to Tools ->
Plugins. Then follow this sequence of screenshots to register nbandroid
update center and install plugin:
92. In Settings tab press Add button and fill name and URL:
• In Available Plugins tab enter android in Search text field, check
found plugin.
• Check also appropriate version of Android Test Runner plugin. (See
below for more details on this topic).
• Press Install
• Press Next
• Accept the license

• Press Continue (and ignore warning about unsigned plugin for now)
• You're done, you can start Android development...
Install from downloadable ZIP archive

• Look for new NBMs (module archives) in our download area


• Unzip them.
• Go to Tools | Plugins | Downloaded
• Click 'Add plugins...' and select all plugins except testrunners that do
not match your IDE version. There are three versions of a module
that provides integration with test results window targets to
NetBeans 6.9 or 6.9.1 or 7.0 users. Each of them is named org-
netbeans-modules-android-testrunner*.nbm.

• Select org-netbeans-modules-android-testrunner.nbm if you are


using NetBeans 7.0 or newer.
• Select org-netbeans-modules-android-testrunner691.nbm if you
are using NetBeans 6.9.1.
• Select org-netbeans-modules-android-testrunner69.nbm if you
are using NetBeans 6.9.
• Click 'Install'. Do not forget this step. You will have to accept license
then. In adittion to that you will be warned that plugins are not
signed.

Install from our continuous build

If you want to get fresh bits rather than less frequently but perhaps more
stable bits from our download area you can register an autoupdate
center generated by nbandroid continuous build. This one is updated
after each code integration that passes tests suite. Address of this
update center is
http://deadlock.netbeans.org/hudson/job/nbandroid/lastStableBuild/
artifact/build/updates/updates.xml. Steps to register this update center
are very much the same as when registering the update center
described above except the different URL. Again go to Tools -> Plugins.
Then follow this sequence of screenshots to register nbandroid update
center and install plugin:
• In Settings tab press Add button and fill name and URL:

• In Available Plugins tab enter android in Search text field, check


found plugin.
• Check also appropriate version of Android Test Runner plugin.
• Press Install
• Press Next
• Accept the license
• Press Continue (and ignore warning about unsigned plugin for now)
You're done, you can start Android development...

Configure Netbeans For Android


development
I just configured my netbook to do android development in netbeans. So
just sharing my experience here. Before I start below is the details of
the hardware and software
Hardware:
Acer Aspire One
Software:
OS: Ubuntu Netbook Remix 10.10
Others: Netbeans IDE 7 M2,Android SDK
There is a nice plugin for Netbeans available called nbandroid and can
be found at http://kenai.com/projects/nbandroid/ . I installed this plugin
to my Netbeans IDE from the update center. To do so you can follow
the instructions at http://kenai.com/projects/nbandroid/pages/Install .
Once installed next I need to download and install the Android SDK
from http://developer.android.com/sdk/index.html . In my case I have
chosen the linux sdk. You can choose the one appropriate to your
platform. Once downloaded do exract it to a folder.Next you can follow
the steps given in http://developer.android.com/sdk/installing.html. But
you can easily skip all the steps about installing eclipse (that is steps
1,3) as we are not going to use eclipse as the IDE. In the instruction the
most important part is at step 4. This step lets you configure and add
the platforms to your sdk tools. next you need to add the android
platform to your netbeans ide. To do so please follow the given steps
1) From the top menu select tools -> Java Platforms
2) The java platforms dialog will open.
3) click add platform

4) Select Google Android Open Handheld Platform, click next and it will
ask you to choose the sdk folder.
5)Next you will have to select the target platform from the list
6) Please select the platform of your choice and click finish to complete
the wizard.
Now you are all set to create an android application in netbeans. You
can just create a new android project and start coding on it. Just a word
of caution in my case the emulator took some time to start. It could be
due to the fact that i m using an Intel atom based laptop.
Do enjoy coding for android and let me know your feedback

You might also like