Broken Vietnamese on Android

I was using Liberty ROM (android 2.3.3) on my Droid X and Vietnamese looks broken (all the diacritical marks are mixed up: acute become grave the press goes above the character instead of below), while the same characters displayed just fine on another phone.

I tried to install the new Roboto font from Android 4.0 via ROM Toolbox but it doesn’t fix the problem.

So I tried to copy the fonts from my other phone running Android 2.3.5 and now everything’s fine. Extract the font file, mount / as writable in ES File Explorer, copy the files to /system/fonts and you are set 🙂

Here are the font files (I guess they are free to distribute since they comes from AOSP)

Resolving ClassCastException using ADT’s visual designer

Recently when maintaining an old android program I encountered a strange exception when attempting to view a layout in visual designer:

error!
ClassCastException: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- TableLayout (Change to android.widget.TableLayout, Fix Build Path, Edit XML)

Searching stack overflow and Android developers, I found this could be caused by using an old version SDK for an application targeted to a newer version, with new elements. But TableLayout was available since API level 1, and I’m using the latest version of the development tools, so these could not be the problem. The temporary fix was to remove the table layout and replace it with something else.

Today I have the time to compare my code to Android’s example. It turned out to be one tiny little thing that messed the designer up:

<TableLayout

			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:orientation="vertical"
			android:stretchColumns="">

There, one attribute doesn’t match the schema (it should be 0 or 1, not empty “”), and the designer will refuse to load. Worse still, the code will compile but will crash at run-time for the same reason.

My recommendation? Android team should note this case and provide better details on the loading exception in upcoming versions. “ClassCastException” is not really helpful!

 

Debugging the Galaxy Tab 10.1

When I first plug the tab in, my computer automatically install all the drivers, but it won’t show up in ADB and Eclipse. I did a little searching but people were pointing me to Samsung’s developer page with a USB driver for phones. Sadly that driver just isn’t for the tab, a search on their site found nothing interesting either. It looks like Samsung can’t keep information for developers updated while they are still battling legal issues around the tab.

Fortunately, I remembered I haven’t turned debugging mode on the tab on, so I went ahead and do it, this time… Success!

Where to turn on debugging

Device in Eclipse

Now I’m installing Android 3.1 platform and looking forward for a happy time debugging 🙂

Debug on Android device

I once thought I just have to plug the device in, install all the driver and when it appeared in ADT’s device window I can just start debugging; but sadly this is not the case. Here’s a very informative guide on how to do so by Google.

Because I was too lazy to read that, I can start the program but it will not hit any breakpoint I set. I missed the first point in the guide above: I have to set debug=”true” in the application’s manifest!

<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">