×
Namespaces

Variants
Actions
(Difference between revisions)

Cross-platform development for Nokia X & Asha

From Nokia Developer Wiki
Jump to: navigation, search
shai.i (Talk | contribs)
(Shai.i -)
BuildNokia (Talk | contribs)
(BuildNokia - Edited for clarity, formatted for wiki)
Line 1: Line 1:
 
[[Category:Nokia Asha]][[Category:Nokia X]][[Category:How To]][[Category:Tutorial]]
 
[[Category:Nokia Asha]][[Category:Nokia X]][[Category:How To]][[Category:Tutorial]]
 
<br />
 
<br />
{{Abstract|This article talks about cross-platform development for Nokia X & Asha from the point of view of current Asha lwuit developers.}}
+
{{Abstract|This article explains how to migrate Asha LWUIT apps to Codenameone so they can be published on the Nokia X platform.}}
 
{{Note|This is an entry in the [[Nokia X Wiki Challenge 2014Q1]]}}
 
{{Note|This is an entry in the [[Nokia X Wiki Challenge 2014Q1]]}}
 
{{ArticleMetaData <!-- v1.3 -->
 
{{ArticleMetaData <!-- v1.3 -->
Line 25: Line 25:
 
== Introduction ==
 
== Introduction ==
  
If you previously developed apps for Nokia Asha/Series40 devices than you are probably familiar with [http://developer.nokia.com/resources/library/LWUIT/ LWUIT] as it is one of the main platforms for building apps for Asha/Series40 devices with its rich UI & customizable wealth of components.<br />
+
If you previously developed apps for Nokia Asha/Series40 devices than you are probably familiar with [http://developer.nokia.com/resources/library/LWUIT/ LWUIT] as it is one of the main platforms for building apps for Asha/Series40 devices, with its rich UI & customizable wealth of components.<br />
In this article i will introduce you to [http://www.codenameone.com codenameone] development platform which will help you to use your existing lwuit skills & know-how to cross-develop for Nokia X & Nokia Asha.
+
In this article I introduce the [http://www.codenameone.com 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 who i know both in person and i must say they are both great developers.<br />
+
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.<br />
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 [http://store.ovi.com/content/357751 Snowman builder] or even partly static games such as [http://store.ovi.com/content/335135 TicTacToe] and my latest highly dynamic high fps game [http://store.ovi.com/content/516633 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.<br />
+
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 [http://store.ovi.com/content/357751 Snowman builder], or even partly static games such as [http://store.ovi.com/content/335135 TicTacToe] and my latest highly dynamic high FPS game [http://store.ovi.com/content/516633 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.<br />
{{Note|The links to Nokia X content currently cannot be viewed via desktop, the urls for the above 3 apps are: http://store.ovi.com/content/516558 http://store.ovi.com/content/516500 http://store.ovi.com/content/439105}}  
+
{{Note|As the links to Nokia X content currently cannot be viewed via desktop, the current URLs for the above 3 apps are: [http://store.ovi.com/content/516558 Snowman builder] [http://store.ovi.com/content/516500 TicTacToe] and [http://store.ovi.com/content/439105 FlapFlap]}}  
 
+
  
 
== Imports ==
 
== 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.*
+
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 {{Icode|com.sun.lwuit.*}} is now {{Icode|com.codename1.ui.*}}
 
<br />
 
<br />
 +
<code java>
 
import com.sun.lwuit.Display;  ===>    import com.codename1.ui.Display;<br />
 
import com.sun.lwuit.Display;  ===>    import com.codename1.ui.Display;<br />
 
import com.sun.lwuit.Form;      ===>    import com.codename1.ui.Form;<br />
 
import com.sun.lwuit.Form;      ===>    import com.codename1.ui.Form;<br />
 +
</code>
  
 
== Resource file ==
 
== 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.
+
If you wish to port an existing application from LWUIT to Codenameone and want to use your existing {{Icode|.res}} file then you should know that the LWUIT {{Icode|.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 {{Icode|.res}} file.
 
[[File:cn1_import_feature.png]]
 
[[File:cn1_import_feature.png]]
{{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}}
+
{{Note| Another nice side benefit from transition to the new {{Icode|.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 ==
 
== Specific Asha components ==
  
Nokia specific version of LWUIT has some components and features that were unique to its Asha platform such as {{Icode|HeaderBar}}, {{Icode|TimePicker}}, {{Icode|ContextMenu}}, etc.<br />
+
The Nokia-specific version of LWUIT has some components and features that were unique to its Asha platform, such as {{Icode|HeaderBar}}, {{Icode|TimePicker}}, and {{Icode|ContextMenu}}.<br />
While you wont be able to use these specific components you could use either their codenameone replacements such as the {{Icode|InfiniteProgress}}, {{Icode|DateTimeSpinner}}, {{Icode|PopupDialog}}, etc. or try and build your own component.<br />
+
 
Other than the Nokia custom components most of the other components exists in both platforms such as Labels, Buttons, Forms, Dialogs, Checkbox, etc.<br />
+
While you won't be able to use these specific components, you could use either their Codenameone replacements, such as the {{Icode|InfiniteProgress}}, {{Icode|DateTimeSpinner}}, and {{Icode|PopupDialog}}, or try to build your own component.<br />
 +
Other than the Nokia custom components, most of the other components, such as Labels, Buttons, Forms, Dialogs, and Checkbox, exist in both platforms.<br />
  
 
== The build process ==  
 
== 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.<br />
+
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.<br />
 
[[File:cn1_build_android_asha.png]]<br />
 
[[File:cn1_build_android_asha.png]]<br />
Once you send the build you can view its progress and its failed/succeed status in the [http://www.codenameone.com/build-server.html codenameone server page]
+
Once you send the build to the Codenameone cloud servers you can view its progress and its fail/success status in the [http://www.codenameone.com/build-server.html 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.<br />
+
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.<br />
{{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}}
+
{{Note|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 ==
 
== 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.
+
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.

Revision as of 23:37, 17 April 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 is an entry in the Nokia X Wiki Challenge 2014Q1

Article Metadata
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 (17 Apr 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 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. 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;<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 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.

243 page views in the last 30 days.
×