If you have developed your Java library that you would like to use within your Android project, or you want to use an existing Java library, make sure that the library itself is compiled with Java 1.6 rather than 1.7. Have been always forgetting that and have wondering for a couple of days why am I getting “NoClassDefFoundError” error.
Tag: android
Google Maps Android class
For an easy way to get directions in native Google Maps App from your own application with two simple lines:
Map newMap = new Map(this, "Ioannina, Greece"); newMap.openMap();
Code on gitHub.
Android SQLite Adapter class
Working with an SQLite database on Android can require some times more effort than what you should really give. For instance, if you ship a pre-configured and populated database with an application, you would need first to copy over the database to the specific database directory and then open it for reading and/or writing data to it. The SQLiteOpenHelper class provides a few methods that make life a bit easier but it does not provide a copy method for handling this issue. In addition to this, a check method would be required before copying the database and so on. Following on this, I implemented a SQLite adapter class to cover my needs as bellow:
– Copy database to the correct directory.
– Open and close the database.
– Execute raw SQL query.
– Execute SQL query for string, int, long, double.
– Drop table.
– Return count of a table.
– Download a db copy from Internet and replace local one.
Android SDK x86_64 – adb, libraries, emulator issues
I have installed the latest Android SDK on Fedora 17 x86_64 version. I’ve chosen the bundle for my platform, expecting it would work straight away, but that was not the case. The adb (Android Debug Brdige) needs to make use of the of libraries for the i686 version, such as glibc, ncurses and tdc++. Errors look as usual:
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
In addition to these I required to install libz for the SDK to perform correctly without any errors. Simply linking from /lib64 to /lib wouldn’t work, as adb would exit with segmentation fault, something expectable since it deals with different architecture’s libraries. The following command will install all the required packages (with a couple of dependencies) to get that bit working:
yum install glibc.i686 ncurses0libs.i686 libstdc++.i686 libzeitgeist.i686
In addition to the libraries issues for the adb, the emulator binary that lunches the Android emulation images is also targeted for i686. The bundle comes with emulator-x86_64 but when you lunch an AVD (Android Virtual Device) through the ADT Manager, it wouldn’t start the emulator as the binary was failing to execute and wouldn’t pick automatically the x86_64 version. In this case a simple link would work. I renamed the initial i686 binary to emulator-32, and linked emulator-x86_64 to emulator. The actual AVD would then start as it should and operated normally, being able to install applications via the Android SDK.