4

Does anyone know if we can use c++ exceptions in Android c++ code, use the STL, and target old releases of Android (for me specifically 2.2)?

I know that previously the NDK did not support exceptions. I know that there used to be libraries that supported exceptions but not the STL. I know that the latest NDK supports exceptions and the STL and creates code that runs on 2.3.

But I'd like to write some code that runs on 2.2 and preferably earlier releases, uses the STL, and uses exceptions. I'm a bit confused about the releases of Android, of the SDK, and of the NDK, and how they connect. To put it another way, can I use the latest library version on older version of the Android OS?

Martin Ellison
  • 1,043
  • 1
  • 13
  • 25

1 Answers1

3

Perhaps this will help: Android NDK R5 and support of C++ exception

Community
  • 1
  • 1
Zac Bowling
  • 6,508
  • 1
  • 27
  • 26
  • So which SDK releases is NDK R5 compatable with? Does it only work with Android 2.3? – Martin Ellison Feb 11 '11 at 10:10
  • In theory, the NDK should work for all devices back to 1.5, with the exception of calling NativeActivity which was added in 2.3. Which means you still have to write Java (with JNI exports) to bridge to native code if you want to run on anything earlier. 2.3's NativeActivity allows you to write a pure native app without touching Java. – Zac Bowling Feb 11 '11 at 11:21
  • thanks Zac. I've now done a test and it does seem to be working (using gnustl_static, NDK v5, and Android 2.2). I had some problems loading my library (dlopen errors) but that seems to be an unrelated issue. – Martin Ellison Feb 11 '11 at 16:47