the Flagship of independent news, reviews and resources for Developers and Users of Samsung's mobile platform Bada
Bada Tutorials, Fundamentals

Components development for bada (Part 3)

wit, January 25th, 2010

When getting started with development of static libraries for bada apps, there are some more points to take into account that I have not discussed in the previous posts (part1, part2).

  1. How to debug your static library with a host project correctly
  2. Static resources (like images) that are needed by your library
  3. Where to link the libraries needed by your static library

These how to points are explained here.

First of all, when you are still developing your library you will want to test/debug it.  Most likely you will create a simple bada project that will link to your static library and use the desired library functionality there. Nevertheless, as time goes by and you change the contents of your library, there is an important thing you have to do within your host project: clean it.

I have found that, if I change and rebuild the library project and rebuild the host project afterward, the new functionality will not be automatically available in the host project. I suspect the reason for this is that the host project still keeps an earlier copy of the static library within the executable, when you build the host project it merely addresses the new code of this project, but does not automatically look for changes in the static library. You have to clean the host project to force it to look for a new copy.

To do so, right-click on the host project and select “Clean Project”:

Then you can build it: the new functionality of your static library shall be available now.

There may also come a time when you need static resources, like images, for functionality within your static library. Imagine, for instance, that you are developing a file save/load dialog that you will reuse in many bada application projects. Furthermore, imagine you need a folder icon to make it more pretty. Where do you  put it? How do you reference it?

I have found that if you reference an image through a static location within the library, since the library later on becomes part of the executable file, the location of the image is actually looked for within the file structure of your host project.

Therefore using a static library in a project not only means you have to link it, but also put the necessary static resources in the right location within your host project. This has to be taken into account when explaining the right way of deployment of your libraries to other developers.

Finally, your static library may also need the functionality of other bada libraries (or completely different libraries), that are not needed in your host project. However, if you take a look at the project properties of your static library, you may notice, that there are no linker settings. This is because the linker is only invoked in bada application projects when building the final executable. Therefore all libraries needed by your static library have to be referenced by your host project. This is another thing to remember for deployment.

Furthermore, you have to be careful with the order of the libraries when you link them. Let’s say your library “libBadaDevCC” needs a bada library FIo that is not needed within your host project “SimpleDrawing”. Nevertheless, you still have to reference it in your host project and it has to come after your static library “libBadaDevCC” !!! If you do not do this, you may get this kind of errors described on our bada community forum.

So, as a rule of thumb, always put your custom libraries on top! :-)

UPDATE: If your library needs some specific functionality that requires certain privileges, these privileges have to be defined in the manifest.xml of the host project.

Related posts:

  1. Components development for bada (Part 2)
  2. Components development for bada (Part 1)
  3. Bada Development- How to Start?

Post a Comment

Editor's picks

Copyright 2009-2010 BadaDev.com (unless otherwise stated). All rights reserved! Powered by Wordpress!