×
Namespaces

Variants
Actions

Cross-platform development for Nokia X & Asha

From Nokia Developer Wiki
Jump to: navigation, search
Featured Article
04 May
2014

This article explains how to migrate Asha LWUIT apps to Codenameone so they can be published on the Nokia X platform.

Note.pngNote: This article was a winning entry in the Nokia X Wiki Challenge 2014Q1

Article Metadata
Code Example
Source file: github
Tested with
SDK: Nokia Asha sdk 1.1, Nokia X SDK
Devices(s): Nokia Asha 501, Nokia X
Compatibility
Platform(s):
Nokia Asha
Dependencies: Codenameone
Article
Created: shai.i (14 Apr 2014)
Last edited: BuildNokia (02 Jun 2014)

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 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.

Note.pngNote: As the links to Nokia X content currently cannot be viewed via desktop, the current URLs for the above 3 apps are: Snowman builder TicTacToe and FlapFlap

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. 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;

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 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. Cn1 import feature.png

Note.pngNote: Another nice side benefit from transition to the new .res file format is that it can also be in XML, which makes it easy to work on the file as a team.

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.

Cn1 build android asha.png

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.

Note.pngNote: Also, every build you send to the server costs 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 to make it possible for LWUIT developers to use their existing code-base.

This page was last modified on 2 June 2014, at 23:48.
249 page views in the last 30 days.
×