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 over the next few weeks. Thanks for all your past and future contributions.
Cross-platform development for Nokia X & Asha
This article explains how to migrate Asha LWUIT apps to Codenameone so they can be published on the Nokia X platform.
Note: This article was a winning entry in the Nokia X Wiki Challenge 2014Q1
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 introduce the Codenameone development platform. Codenameone will help you use your existing LWUIT skills and knowledge to cross-develop for Nokia X & Nokia Asha. Codenameone is open sourced and developed by the people who initially developed LWUIT. I know both of them 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 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. All of the above-mentioned apps are also currently published to Nokia X, proving that Codenameone is a viable option for developing and publishing cross-platform apps.
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. What was previously com.sun.lwuit.* is now com.codename1.ui.*
import com.sun.lwuit.Display; ===> import com.codename1.ui.Display;
import com.sun.lwuit.Form; ===> import com.codename1.ui.Form;
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 is 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.
Specific Asha components
The Nokia-specific version of LWUIT has some components and features that were unique to its Asha platform, such as HeaderBar, TimePicker, and ContextMenu.
While you won't be able to use these specific components, you could use either their Codenameone replacements, such as the InfiniteProgress, DateTimeSpinner, and PopupDialog, or try to build your own component.
Other than the Nokia custom components, most of the other components, such as Labels, Buttons, Forms, Dialogs, and Checkbox, exist in both platforms.
The build process
With 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 run the build on the Codenameone cloud servers.
Once you send the build to the Codenameone cloud servers you can view its progress and its fail/success status in the Codenameone server page.
Before sending a build, you should test it thoroughly on the Codenameone emulator to avoid wasting time waiting for the server to finish building its queue.
While Codenameone can be used to develop for other platforms as well, I mainly focused on Nokia X & Nokia Asha in this article to make it possible for LWUIT developers to use their existing code-base.