Porting case: Frozen Bubble


This porting story represents a case where a direct port of the application was feasible, and where large parts of the application were reused. The story focuses mainly on the changes that were necessary to get the game to run smoothly on Nokia Asha devices.

This Java ME example application demonstrates how to port a full-screen touch-controlled game from Android to Java ME in Nokia Asha devices. The code is based on the Android version of Frozen Bubble, created by Pawel Aleksander Fedorynski. The Android version is ported from Java version of Frozen Bubble created by Glenn Sanson. The original Frozen Bubble was created by Guillaume Cottenceau (programming), Alexis Younes and Amaury Amblard-Ladurantie (artwork) and Matthias Le Bidan (soundtrack). The Java ME port, just like the original Frozen Bubble, is covered by GNU GPL v2.

Figure 1. Frozen Bubble for Android

Figure 2. Frozen Bubble for Nokia Asha

In the port from Android to Nokia Asha software platform, the same game logic code and most of the resources were reused, while new code was written for starting up the game, handling menus and playing sounds. For more information on porting, design, and implementation of the application, see project wiki.

Necessary changes to run the game in Java ME

The first step was to locate all classes which don't exist in Java ME. The main classes which needed rewriting before the game could be run were the main activity class FrozenBubble and the GameView class. The FrozenBubble class was rewritten to extend MIDlet to provide a starting point for the game, and the GameView class was replaced with a FrozenCanvas class. The FrozenCanvas class extends GameCanvas and provides a canvas for drawing, like the GameView provided a canvas by extending SurfaceView. GameView also contained a main loop of the game as a GameThread class. The Java ME version also has a GameThread to run the main loop, but it is much simpler and the only job it has is to call FrozenCanvas#runGameLoop method periodically.

Classes with red background were basically completely rewritten.

Figure 3. Architecture of the Android version

Figure 4. Architecture of the Java ME version

Saving game state

Frozen Bubble for Android uses SharedPreferences to store a current level permanently and Activity#onSaveInstanceState(Bundle outState) method to save the state of the game in the level temporarily, so that, for example, an in-coming call or other event won't reset the game state in the level. In Nokia Asha software platform there is no guarantee that a MIDlet is not killed when a call or some other event takes focus, so all calls to save and restore the state to and from a Bundle were rewritten to use byte streams and all the data is stored in RMS permanently.


Android provides an options menu, but Java ME does not provide any similar functionality, so a menu screen was implemented.

Figure 5. Options Menu in Android

Figure 6. Menu in Java ME

Resizing image resources

Android provides methods for scaling images, but Java ME does not provide any such methods, so an implementation of pixel mixing algorithm was written for downscaling images, and bilinear filtering algorithm was written for upscaling images. Scaling of all the images is done in the initialisation phase of the game, and because it takes a while a splash screen was added to show the progress.

Figure 7. Splash screen

Rotating images

Android provides methods for drawing rotated images, but Java ME does not provide any such methods, so a workaround was needed. There were basically two possibilities: write new code for rotating images, or create rotated images and include them all in the game package. As scaling of images is quite a slow operation, rotating would probably be slow as well, and rotated images would need to be calculated in the initialisation phase and stored in the memory. In this project only the launcher image needed rotating and the number of steps was small, so the image was rotated in an image editor, and there was no need to write new code.

Figure 8. Rotated images

Optimizing Memory Usage

Generally, Android devices have more memory, so using big images does not cause problems. Java ME devices don't always have so much memory, so some images were modified to use less memory. For example, the background was cropped and modified to a smaller size.

Figure 9. Background in Android Version

Figure 10. Background in Java ME Version

Adaptation to smaller resolution

The screen resolution on Android devices is usually bigger than in Java ME devices, so the font used in the Android version of the game didn't work really well in the Java ME version. Because of this a new font was created. The new font is simpler than the original and stays readable when it is downsampled.

Figure 11. Original Font

Figure 12. New Font


The Android version uses ogg files and SoundPool for playing the game sounds. Java ME doesn't have a counter part for the SoundPool class, so the SoundManager class was rewritten to support the same functionality using the Player class. Ogg format was also not supported by the Nokia Asha devices, so all the files were converted to wav files.

Read more & download

Full implementation details, including code snippets and full source code, can be found in the project wiki.

Last updated 11 July 2013

Back to top