I am trying to use the NDK 5 full C++ gnustl:
The CPLUSPLUS-SUPPORT.html
states:
The NDK toolchain supports C++ exceptions, since
The NDK-r5 tools support the use of exceptions and RTTI in C++ code. The use of an STL other than the GNU STL as a static library is not, however, supported, in the presence of RTTI or exceptions.
The STLport supplied is not usable together with exceptions or RTTI.
Note that it may be necessary to clean the build objects when swapping between STL implementations.
As far as I know, the Android NDK has never supported exceptions. libstdc++ itself does support exceptions, but when compiled for android, exception support is turned off (grep for "-fno-exceptions").
See this thread on the android ndk mailing list.
I have a similar problem using JNI. All exceptions thrown from a JNI method are causing a SIGILL error under Android 1.6 and 2.1. It's working fine under Android 2.2+
See my issue (please don't hesitate to vote for it or post a comment) :
http://code.google.com/p/android/issues/detail?id=20176
So, currently, Android 1.6 and 2.1 don't support exceptions from JNI methods with the last NDK.
Perhaps could it be fixed in a future NDK release...
It turns out that exceptions work but only if the exception are inherited from std::exception. In my case the exception hierarchy did not always include std::exception which broke the catch/throw. Curiously the throwing strings as exceptions works when compiled for x86/Mac OS. I have fixed my problem by modifying the exceptions I use.