Monday, January 24, 2011
Thursday, January 13, 2011
Lwuit for blackberry and android
This document is not supposed to be a guide for LWUIT . I want to provide some information for interested LWUIT programmers to extend their reach to the BlackBerry and Android platforms. If you have never worked with these targets before, don't forget to read some of the available developer documentation. There is way too much important information to put into one place. But this document should help you by giving a working example and providing links to other resources along the way.
I won't go into much detail on how to install and use the required software tools. Please read the documentation that comes with each software and search the Web, or ask for help in a forum. I assume that you already use an IDE like Netbeans or Eclipse. So you do not have to run the build scripts from the command line and can just integrate them into your projects. To improve your efficiency you probably want to install a BlackBerry/Android plugin for your IDE. If you do that, you do not have to use the scripts that I provide here. But they can give you an idea about the build procedure.
The ANT scripts copy all the source files to a separate directory and compile your application there. This allows you to use separate library-type projects within your IDE environment and use the scripts to put the pieces together.
I have taken a sample application from the LWUIT blog and modified it a little. First download the sample application sources and the build files . The archive contains the application itself and two ANT scripts, one for each platform. You still need to get the LWUIT sources and the LWUIT implementations for BlackBerry and Android from the Subversion repositories . You really should get up-to-date copies from the repository and not the LWUIT binaries.
Building for BlackBerry
The LWUIT blog describes in detail how to build LWUIT applications for BlackBerry with Netbeans. That is a very nice step-by-step guide to get going with Netbeans and an alternative to the approach that I take here.
Install first:
Apache ANT
bb-ant-tools
Antenna
SUN WTK 2.5.x
BlackBerry JDE 4.3 and 4.7
bb-ant-tools
Antenna
SUN WTK 2.5.x
BlackBerry JDE 4.3 and 4.7
There are two LWUIT implementations for BlackBerry right now. This ANT file uses the official implementation. The sources can be found in the BlackBerry subdirectory within the LWUIT Subversion repository . I have my own implementation in the LWUIT-Incubator that you could use, but you would have to do a few adjustments. In the long run there is going to be only the official one.
The build file compiles your application for the BlackBerry Operating Systems version 4.3.0+ and for 4.7.0+. Read the BlackBerry developer documentation about BlackBerry OS versions and compatibility issues. The 4.7.0 build will run on touch screen and non-touch screen devices that run BB OS 4.7 or later.
You need to configure the variables within the 'ADJUST THIS TO YOUR ENVIRONMENT' comments. And you need to adjust the 'getsources_430' and 'getsources_470' targets. These targets copy all the source and binary files from your project locations to a temporary directory. Make sure to copy the LWUIT sources, the LWUIT BlackBerry implementation sources and the application sources into one directory. The same has to be done for any binary files that you might need for your application.
Finally run the 'buildblackberry' target to build the files. If you run the script from the commandline type:
ant -f build_blackberry.xml buildblackberry
ant -f build_blackberry.xml buildblackberry
If everything works as expected you will end up with a lot of files in the 'bb_bin_430' and 'bb_bin_470' directories. You only need the ALX/COD file pair for installation using the BlackBerry Desktop Manager and the 'bb_bin_430/smallcod' and 'bb_bin_470/smallcod' directory contents for OTA installation.
The ANT script does not include obfuscation and signing, but it can easily be added. Obfuscation might not be that important as the BlackBerry build process already provides some level of obfuscation.
To see how the sample looks you can install it OTA on your BlackBerry by using the proper link below:
For BB OS 4.3 and later: lwuitlist.jad (No touch screen support)
For BB OS 4.7 and later: lwuitlist.jad (With touch screen support)
For BB OS 4.3 and later: lwuitlist.jad (No touch screen support)
For BB OS 4.7 and later: lwuitlist.jad (With touch screen support)
Building for Android
Install first:
Apache ANT
Android SDK 2.0 or later
Android SDK 2.0 or later
Note that signing your application for Android is mandatory. The good news is that it is free, you can use your own certificates.
The ANT file builds your application for Android OS 1.5 and later. It should work on any future device, provided that you design your application to work with any resolution, touch screen or no touch screen, hardware keyboard or not, screen density, ... . LWUIT gives you the tools to do that, it's up to you to use them.
Configure the variables within the 'ADJUST THIS TO YOUR ENVIRONMENT' comments. Additionally you need to adjust the 'getsources' target. This target should copy all the source and binary files from your project locations to a temporary directory. Copy the LWUIT sources, the LWUIT Android implementation sources and the application sources into one directory. The same has to be done for any binary files that you might need for your application.
If you run the script from the commandline type:
ant -f build_android.xml buildandroid
ant -f build_android.xml buildandroid
In the end you will have an APK file within your 'android_bin' directory that you can use to install on the emulator or on real devices.
To see how the sample looks you can install it OTA on your Android device or emulator by using the link below:
For Android OS 1.5 and later: http://www.pader-sync.com/LWUITList.apk
For Android OS 1.5 and later: http://www.pader-sync.com/LWUITList.apk
Source: http://www.pader-sync.com/lwuit-for-blackberry-and-android.html
____________________________________________________________________
Lwuit,Lwuit for Android,Lwuit for Android, LWUIT programmers, blackberry
Subscribe to:
Posts (Atom)