سؤال

I want to create a Java Bindings library for the PocketSphinx Android Demo project for Xamarin, that I can then use in my Android application. I have done the following:

  • downloaded the PocketSphinxAndroidDemo project, and installed and run it on my Android device using Eclipse without any issues - the native java code works nicely.
  • created a Java Bindings library in Visual Studio with the pocketsphinx-android-0.8-nolib.jar file marked as an EmbeddedJar and marked Copy to output directory always and got this to compile fine. I'm using the jar from the downloaded demo project.
  • added an android application project to my Visual Studio solution and added a reference to my bindings library.
  • added lib/armeabi/libpocketsphinx_jni.so to my application project (also armeabi-v7a) (using the files from the demo project) and marked the *.so files as AndroidNativeLibrary with Copy to Output directory set to Copy Always.

No matter what I do I can't run the line of C# code

var config = Decoder.DefaultConfig();

I always get a Java.Lang.UnsatisfiedLinkError exception (as described in my forum post here). I'm trying to run this line of code because the demo project has this line of java:

Config config = defaultConfig();

My question is, do I need to use DllImport here? Or perhaps Java.Lang.JavaSystem.LoadLibrary? Is this a scenario where the project should be built using ndk-build?

I have tried both DllImport and LoadLibrary with no success. Any leads or things to try much appreciated!

Thanks in advance,

David

هل كانت مفيدة؟

المحلول

Following on from a response that I got in this forum thread, I worked out that I needed to call

Java.Lang.JavaSystem.LoadLibrary("pocketsphinx_jni");

in the OnCreate method of my class, before calling the DefaultConfig method.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top