[mono-android] Fwd: Help with .so and java source
Goncalo Oliveira
goncalo at minkan.net
Fri Feb 17 16:41:52 UTC 2012
Hello,
I'm having a bit of trouble on assembling all this, so maybe you can throw
me some pointers on what I might be doing wrong.
I have a third-party library (.so file) that I want to use in my
application. This third-party library comes with a java source file
(there's also a C header file version) with a bunch of native methods to
access the library.
So, here's what I did
1. Added the .so library to the project under
/NativeLibraries/armeabi/libsdk.so
2. Set the library's build action to AndroidNativeLibrary
3. Added the java source file under /JavaSources/libmsg.java
4. Set the file's build action to AndroidJavaSource
After these steps, I created a static helper class to access the java
source file with JNI
public static class LibAPI
{
private static IntPtr _Class = JNIEnv.FindClass(
"com/alk/sdk/AlkMsg" );
[...]
public static int HasStarted()
{
IntPtr methodId = JNIEnv.GetStaticMethodID( _Class,
"Msg_HasStarted", "()I" );
return ( JNIEnv.CallStaticIntMethod( jClass, methodId ) );
}
[...]
The java source file goes by
package com.alk.sdk;
public class AlkMsg {
[...]
public static native int Msg_HasStarted();
[...]
I compile the whole thing, deploy to device and start debugging. When I
click the button that calls the LibAPI.HasStarted() I get
an Java.Lang.UnsatisfiedLinkError.
What am I doing wrong here? At first I thought that there could be
something wrong with the .so file because it's larger than 1 mb, but
apparently that is not an issue for .so files, only assets.
Should I consider "P/Invoking" the whole thing and drop the java source?
I look forward to hear your thoughts on this, maybe you can throw me some
pointers, as I'm a bit lost at the moment.
Cheers
--
Gonçalo Oliveira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120217/088d36e3/attachment-0001.html>
More information about the Monodroid
mailing list