Q:

Android NDK - moving .so files from one project to another

I have a small project I've coded for Android that uses a small about of NDK/JNI code. I'd like to share this code between two projects but I'm having little luck so far. First off, I've tried to refactor off the NDK specific code into a library which I think link to both projects using 
'project->java build path->source->link source'
and specifying the native library in there. Sounds good but it's wrong. The project from which I refactored the code still requires the .so library file in 
MyOriginalProject\libs\armeabi\MyNativeLibrary.so
Removing that from the original project whilst still linking the source of the refactored library fails.
Secondly, creating a new project and attempting to use the NDK library I wrote by both including the source of the library and copying over the .so files from 'obj' and 'libs' into the root directory of the new project fails. It seems to pass
System.loadLibrary("MyNativeLibrary")
At least, it didn't assert.
The code gets as far as my first NDK call and then crashes without being caught by my exception handler.
Any hints would be welcome - such as foolproof ways to get NDK to load a library, typical gotchas and NDK debugging techniques.
Thanks in advance,
Tim.

A:

When I worked with the NDK a year ago, I build the .so file with the NDK make. Then I copied the .so from the NDK to the /lib folder of my project. It worked without a problem.
Do the method names in your NDK-Project match the fully qualified class-/methodnames of the classes where you want to call the JNI functions?
If you have a class:
package com.example;
 public class Foo{
  native public void bar();
 }

Then the method in your C file must be something like:
void com_example_Foo_bar();

If that didn't help, could you then post the exception?

