Tools

Namespaces

Variants

Views

Actions

Search

Contents

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

The first thing you need to know when transitioning your apps from lwuit code to codenameone code is that the package names have been re-arranged and also changed so what was previously com.sun.lwuit.* is now com.codename1.ui.*

The first thing you need to know when transitioning your apps from lwuit code to codenameone code is that the package names have been re-arranged and also changed so what was previously com.sun.lwuit.* is now com.codename1.ui.*

Contents

Introduction

If you previously developed apps for Nokia Asha/Series40 devices than you are probably familiar with LWUIT as it is one of the main platforms for building apps for Asha/Series40 devices with its rich UI & customizable wealth of components.
In this article i will introduce you to codenameone development platform which will help you to use your existing lwuit skills & know-how to cross-develop for Nokia X & Nokia Asha.
Codenameone is open sourced and developed by the people who initially developed LWUIT who i know both in person and i must say they are both great developers.
As for me i often find myself using Codenameone for various apps or even games (even though the platform was never intended for games it is do-able) on my Nokia store publisher page http://store.ovi.com/publisher/Future%20soft/ you can find various apps developed with Codenameone that were build for Nokia Asha such as Snowman builder or even partly static games such as TicTacToe and my latest highly dynamic high fps game FlapFlap also note that all the mentioned above apps are also currently published to Nokia X so you can be sure its a viable option to develop and publish with it.

Imports

The first thing you need to know when transitioning your apps from lwuit code to codenameone code is that the package names have been re-arranged and also changed so what was previously com.sun.lwuit.* is now com.codename1.ui.*
[BR]
import com.sun.lwuit.Display; ===> import com.codename1.ui.Display;[BR]
import com.sun.lwuit.Form; ===> import com.codename1.ui.Form;[BR]

Resource file

If you wish to port an existing application from lwuit to codenameone and want to use your existing .res file then you should know that the lwuit .res file is of a much older file version specification and not supported in codenameone however you can try to import its content using the import feature in the codenameone resource editor (which is like the lwuit resource editor) by simply selecting your old .res file.

Note: Another nice side benefit from transition to the new .res file format is that it can also be in XML which help you work on the file in team easily

Specific Asha components

Nokia specific version of LWUIT has some components and features that were unique to its Asha platform such as HeaderBar, TimePicker, ContextMenu, etc.
While you wont be able to use these specific components you could use either their codenameone replacements such as the InfiniteProgress, DateTimeSpinner, PopupDialog, etc. or try and build your own component.
Other than the Nokia custom components most of the other components exists in both platforms such as Labels, Buttons, Forms, Dialogs, Checkbox, etc.

The build process

When you used the lwuit platform the entire build process was done locally on your PC, however in Codenameone in order to build the final binary (APK for Nokia X or Jar & Jad for Nokia Asha) you have to send the build to run on the codenameone cloud servers.
Once you send the build you can view its progress and its failed/succeed status in the codenameone server page
Before sending a build i suggest you test it thoroughly on codenameone emulator to avoid wasting time waiting for the server to finish building its queue.

Note: Also each build you send to the server cost you 1 credit, however as a free user you have 100 credits per month which should be enough

Summary

While Codenameone can be used to develop for other platforms as well i mainly focused on Nokia X & Nokia Asha in this article because of the initial thought of LWUIT developers and utilizing their existing code-base.