2

In my Xamarin.Android app I use native library loaded like JavaSystem.LoadLibrary("my_library") App crashes when any exception occured in this library.

How can I avoid it - safety handle or ignore those exceptions?

Victor Kochetkov
  • 221
  • 2
  • 13
  • You should handle them completely within your shared library (C++ exceptions, etc..), because you can not "catch" them with ART and thus Mono as you can not perform JNI callbacks into Java when in a signaled state. : https://stackoverflow.com/questions/34547199/art-prevents-any-java-calls-from-jni-during-native-signal-handling – SushiHangover Dec 22 '18 at 18:23
  • As a side question, is your shared library dependent upon running in an Java context, i.e. is there are reason you are not using Mono/.Net's native interop? – SushiHangover Dec 22 '18 at 18:58
  • I use SIP library (linphone) in my app. Core of library is native libraries + some c# wrappers. – Victor Kochetkov Dec 22 '18 at 20:15
  • Yes, I know libLinphone, I use it directly in Xamarin.iOS|Android via .NEt interop. – SushiHangover Dec 22 '18 at 22:10
  • I think I'm misunderstanded... I call native libLinphone functions from c# wrapper via [DllImport] - as implemented in official Xamarin example project. Are there another ways to use this library? – Victor Kochetkov Dec 23 '18 at 16:51
  • Why are you using java's loadlibrary function then? – SushiHangover Dec 23 '18 at 18:39
  • I can't call native functions via wrapper (DllImport) without prior execute `JavaSystem.LoadLibrary` - exception occurring and app crushing – Victor Kochetkov Dec 23 '18 at 21:25

0 Answers0