Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:40:21+00:00 2026-06-15T04:40:21+00:00

Is there any way that I can use C++ exceptions in a JNI (Java

  • 0

Is there any way that I can use C++ exceptions in a JNI (Java Native Interface) library on Android?

EDIT: I am talking about C++ exception handling that is entirely internal to the JNI library. That is, the exception is both thrown and catched within the library, and it never escapes the library.

According to the Android documentation (docs/CPLUSPLUS-SUPPORT.html), exceptions are only supported if I use ‘GNU libstdc++’ as the C++ runtime instead of the default.

The problem is that the documentation also states that all parts of a program must use the same C++ runtime:

“You can only select a single C++ runtime that all
your code will depend on. It is not possible to mix shared libraries compiled
against different C++ runtimes.”

According to my interpretation, this means that I am forced to use the same C++ runtime as Dalvik (Java VM on Android).

So, if Dalvik does not use ‘GNU libstdc++’, is there still a way that I can use exceptions in my JNI lib?

What C++ runtime is Dalvik compiled against?

EDIT: I have to assume that whichever Java app is using my JNI library, may also want to use other JNI libraries, that I have no control over. Does that in any way limit my options?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:40:22+00:00Added an answer on June 15, 2026 at 4:40 am

    Yes you can use exceptions with

    APP_STL := gnustl_static
    

    or gnustl_shared. The doc uses kindof intimidating language but they only want you not to mix libraries that expect different STL implementations in your app. That’s why the setting has APP_ prefix, not LOCAL_.

    Dalvik VM fully supports any of the STL implementations listed in the doc.

    Usually you control both sides of your JNI, and can make sure that all native components are compiled for gnustl_shared. This is the preferred scenario.

    If your business is to provide a black box library that may be used by other people who could decide to also include other libraries, it’s safer to choose gnustl_static to support C++ exceptions in your code. This way you don’t depend on others’ good will. You should be careful to design your API so that your native objects (and especially exceptions) never get exposed to other components.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way that I can use C# to load and then render
Is there any way that I can use JavaScript (and jQuery) to create a
Is there any free gate way or a way that I can use to
Is there any way that I can detect browser type on routing and use
Is there a way to globally trap MemoryError exceptions so that a library can
Is there any way that you can detect the resizeHandlers moment of completion? something
Is there any way that we can print the user name of the person
Is there any way that we can mock certain methods using existing objects ?
Is there any way that I can create a new delegate type based on
Is there any way that I can pass arguments in selector? example: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.