Just enabled "Mobile Templates" for this blog: check it out on your iPad, Android, iPhone, or mobile device: it looks really cool on my HTC Evo!
This blog was born as a means of annotating big and small discoveries in my use of Java, Ubuntu/Linux and Android that would be easy to access from anywhere, anytime. It does beat post-it's big time, and it also adds the benefit that others might, eventually, contribute with intelligent insights.
Saturday, March 26, 2011
Mobile templates
Just enabled "Mobile Templates" for this blog: check it out on your iPad, Android, iPhone, or mobile device: it looks really cool on my HTC Evo!
Monday, January 17, 2011
Run Android tests in a connected device
Not quite sure as to why it never occurred to me, but it is totally possible and legal to run unit tests inside a real device, connected to your dev box via a USB cable.
An obvious advantage is that you are now running your tests in a more "realistic" environment; there are no drawbacks that I can think of (unless your device has some weird 'lockdown' imposed by the manufacturer / cell provider); and... that's when you realize just how much faster than an emulator that is.
So here's the day's top-tip: if you are in a hurry, and have a lot of unit test you want to run, get that USB cable out!
An obvious advantage is that you are now running your tests in a more "realistic" environment; there are no drawbacks that I can think of (unless your device has some weird 'lockdown' imposed by the manufacturer / cell provider); and... that's when you realize just how much faster than an emulator that is.
So here's the day's top-tip: if you are in a hurry, and have a lot of unit test you want to run, get that USB cable out!
Saturday, January 15, 2011
Using the same model classes in Android, GWT and JPA (Part II)
In a recent post, I've demonstrated how one can use the same domain-specific (Model) classes end-to-end, from the Mobile layer, to the GWT Front-End, up to server-side and Persistence layer (JPA).
This blog has now been moved to codetrips.com: please read the rest of this post here.
This blog has now been moved to codetrips.com: please read the rest of this post here.
Thursday, December 23, 2010
Android Draw 9-patch seems broken too
As far as I can tell, the current release of the Android SDK (R08) ships without the Swing Desktop jar, and this causes draw9patch to fail.
~$ draw9patch &
[2] 52452
~$ Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/jdesktop/swingworker/SwingWorker
at com.android.draw9patch.Application$1.run(Application.java:48)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
[2]+ Done draw9patch
The 'fix' is rather simple: just download the JAR for Swing Desktop from here, and drop the swinglabs-0.8.0.jar file into the [sdk-install-dir]/tools/lib folder.The Swing Desktop project can be found here.
Go check out Patch 15, it's pretty impressive!
Carrier BIlling comes to Android!
Some of you folks may have recently noticed a little remark at the bottom of an email from the Android Market folks:
Finally, we wanted to bring to your attention that Android Market now offers a new form of payment for users on the AT&T network -- Direct Carrier Billing. This payment option lets Android users on the AT&T network purchase applications more easily.
This is an awesome achievement on the part of the Google folks, which integrates payments made by users into their phone bills, if they are AT&T customers: in turn, this enables us (the developers) to receive our payments via fewer user clicks and in a more streamlined way, so as to smooth the path for the user to purchase our Apps.
And all that, at virtually no additional complexity for us, which is, I'd say, pretty awesome!
I would expect more integrations and more awesomeness in the next few months: stay tuned!
Wednesday, December 8, 2010
Latest update for Android SDK breaks for Ubuntu Karmic
If you have recently updated your Android SDK to R08 (Gingerbread, 2.3) on Linux and are using Ubuntu Karmic, chances are that you will not be able to run the emulator: It will simply die with the following error:
$ ./emulator
./emulator: /lib32/libc.so.6: version `GLIBC_2.11' not found (required by ./emulator)
This is caused by an incompatibility with Karmic's installed GLIBC - the new SDK/Emulator works just fine on Lucid.
The Android team is working on a fix - in the meantime, a workaround is to download the _r07 of the tools from here, and replace emulator in the tools/ folder under the android_sdk installation folder.
A bit hacky, but works.
$ ./emulator
./emulator: /lib32/libc.so.6: version `GLIBC_2.11' not found (required by ./emulator)
This is caused by an incompatibility with Karmic's installed GLIBC - the new SDK/Emulator works just fine on Lucid.
The Android team is working on a fix - in the meantime, a workaround is to download the _r07 of the tools from here, and replace emulator in the tools/ folder under the android_sdk installation folder.
A bit hacky, but works.
Tuesday, November 30, 2010
Using Boost in Ubuntu with Eclipse
Boost is an open source library of extremely useful and carefully designed C++ classes and methods ranging from graph algorithms, to regular expressions matching, to multi-threading.
Part of the Boost library was also integrated into the C++ standard as the TR1 set of libraries.
You can learn more about Boost here.
Using it with Eclipse in Ubuntu is definitely possible, but not straightforward; so I decided to post this simple tip here, to help folk spare some of the grief.
The first step in using Boost in your code is to download the header (.hpp) files and (optionally) source code - the latest release is 1.45 and is available from Boost's website.
In theory, you could compile it, and build the libraries' binaries yourself: by all means, go ahead and do it, but there is an easier way, if you can live with a slightly 'older' version.
Ubuntu 9.10 (Karmic Koala) comes with Boost 1.34 pre-configured (I think, this is, at any rate, the version that I had on my system):
However, by using Synaptic, you can actually install the more recent 1.40.0 version:
This will install a bunch of libboost_*.so.1.40.0 files into /usr/lib: in order to match the libraries with the header files (and avoid introducing incomprehensible compilation errors at best, and subtle bugs at worst) you should download the matching boost_1_40_0.tar.bz2 from Boost download archives.
We would be almost there, were it not for the fact that the soname does not really comply with the -l gcc linker option.
In gcc the -L option specifies a 'search directory' (this would not be needed, as /usr/lib is searched for libraries by default) and the -l specifies additional dynamic (.so) or static (.a) libraries: you specify the file to include during the link step by omitting the `lib` prefix and the .so or .a extension.
In other words, if your HelloBoost source uses code from Boost Regex (libboost_regex.so) you would specify it like thus:
You can see where I'm heading with all this: the last step will be to add symbolic links that do away with the soname suffixes of Boost libraries, and all will be well:
Given that there are in total 24 files for the whole of Boost 1.40, I've done a bit of find & replace magic, and have come up with the following shell file (the other advantage being that, when a later version becomes available for Ubuntu, I will not have to change any of my Eclipse projects setting, but just change the VERSION value in the script):
The last and final step is to tell Eclipse what to look for when building your binary: right-click on your project's folder (in the C++ Perspective, Project Explorer) then Properties > C/C++ Build > Settings, select GCC C++ Linker > Libraries and add the 'stripped' library names in the option list:
Note for the curious: the additional libraries listed there are for Google C++ Unit testing framework, GUnit, available here - you will have to build it, but that's pretty straightforward, resulting in the two libgtest.a and libgtest_main.a libraries - be careful to add those only to your 'Test' configuration and exclude your unit tests from build in your Release/Debug configurations.
Part of the Boost library was also integrated into the C++ standard as the TR1 set of libraries.
You can learn more about Boost here.
Using it with Eclipse in Ubuntu is definitely possible, but not straightforward; so I decided to post this simple tip here, to help folk spare some of the grief.
The first step in using Boost in your code is to download the header (.hpp) files and (optionally) source code - the latest release is 1.45 and is available from Boost's website.
In theory, you could compile it, and build the libraries' binaries yourself: by all means, go ahead and do it, but there is an easier way, if you can live with a slightly 'older' version.
Ubuntu 9.10 (Karmic Koala) comes with Boost 1.34 pre-configured (I think, this is, at any rate, the version that I had on my system):
$ ls /usr/lib/libboost* /usr/lib/libboost_date_time-gcc41-1_34_1.so.1.34.1 /usr/lib/libboost_date_time-gcc41-mt-1_34_1.so.1.34.1 /usr/lib/libboost_date_time-gcc42-1_34_1.so.1.34.1 /usr/lib/libboost_date_time-gcc42-mt-1_34_1.so.1.34.1 /usr/lib/libboost_filesystem-gcc41-1_34_1.so.1.34.1 /usr/lib/libboost_filesystem-gcc41-mt-1_34_1.so.1.34.1 /usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1 /usr/lib/libboost_filesystem-gcc42-mt-1_34_1.so.1.34.1 /usr/lib/libboost_iostreams-gcc41-1_34_1.so.1.34.1 /usr/lib/libboost_iostreams-gcc41-mt-1_34_1.so.1.34.1 /usr/lib/libboost_iostreams-gcc42-1_34_1.so.1.34.1 /usr/lib/libboost_iostreams-gcc42-mt-1_34_1.so.1.34.1 /usr/lib/libboost_regex-gcc41-1_34_1.so.1.34.1 /usr/lib/libboost_regex-gcc41-mt-1_34_1.so.1.34.1 /usr/lib/libboost_regex-gcc42-1_34_1.so.1.34.1 /usr/lib/libboost_regex-gcc42-mt-1_34_1.so.1.34.1 /usr/lib/libboost_signals-gcc41-1_34_1.so.1.34.1 /usr/lib/libboost_signals-gcc41-mt-1_34_1.so.1.34.1 /usr/lib/libboost_signals-gcc42-1_34_1.so.1.34.1 /usr/lib/libboost_signals-gcc42-mt-1_34_1.so.1.34.1 /usr/lib/libboost_thread-gcc41-mt-1_34_1.so.1.34.1 /usr/lib/libboost_thread-gcc42-mt-1_34_1.so.1.34.1
However, by using Synaptic, you can actually install the more recent 1.40.0 version:
This will install a bunch of libboost_*.so.1.40.0 files into /usr/lib: in order to match the libraries with the header files (and avoid introducing incomprehensible compilation errors at best, and subtle bugs at worst) you should download the matching boost_1_40_0.tar.bz2 from Boost download archives.
We would be almost there, were it not for the fact that the soname does not really comply with the -l gcc linker option.
In gcc the -L option specifies a 'search directory' (this would not be needed, as /usr/lib is searched for libraries by default) and the -l specifies additional dynamic (.so) or static (.a) libraries: you specify the file to include during the link step by omitting the `lib` prefix and the .so or .a extension.
In other words, if your HelloBoost source uses code from Boost Regex (libboost_regex.so) you would specify it like thus:
$ gcc -Wall hello_boost.cc -o HelloBoost -lboost_regex
You can see where I'm heading with all this: the last step will be to add symbolic links that do away with the soname suffixes of Boost libraries, and all will be well:
$ ln -s /usr/lib/libboost_regex.so.1.40.0 /usr/lib/libboost_regex.so
Given that there are in total 24 files for the whole of Boost 1.40, I've done a bit of find & replace magic, and have come up with the following shell file (the other advantage being that, when a later version becomes available for Ubuntu, I will not have to change any of my Eclipse projects setting, but just change the VERSION value in the script):
#!/bin/bash
#
# Simple script to enable Boost with simple -l gcc option
# Use: gcc -Wall hello_world.cc -o HelloWorld -lboost_regex
#
# Created by M. Massenzio, 2010-11-30
VERSION=1.40.0
for libname in libboost_date_time \
libboost_filesystem \
libboost_graph_parallel \
libboost_graph \
libboost_iostreams \
libboost_math_c99f \
libboost_math_c99l \
libboost_math_c99 \
libboost_math_tr1f \
libboost_math_tr1l \
libboost_math_tr1 \
libboost_mpi \
libboost_prg_exec_monitor \
libboost_program_options \
libboost_python-py25 \
libboost_python-py26 \
libboost_regex \
libboost_serialization \
libboost_signals \
libboost_system \
libboost_thread \
libboost_unit_test_framework \
libboost_wave \
libboost_wserialization
do
ln -s /usr/lib/$libname.so.$VERSION /usr/local/lib/$libname.so
done
The last and final step is to tell Eclipse what to look for when building your binary: right-click on your project's folder (in the C++ Perspective, Project Explorer) then Properties > C/C++ Build > Settings, select GCC C++ Linker > Libraries and add the 'stripped' library names in the option list:
Note for the curious: the additional libraries listed there are for Google C++ Unit testing framework, GUnit, available here - you will have to build it, but that's pretty straightforward, resulting in the two libgtest.a and libgtest_main.a libraries - be careful to add those only to your 'Test' configuration and exclude your unit tests from build in your Release/Debug configurations.
Subscribe to:
Posts (Atom)

