UnsatisfiedLinkError

Put problems with the Android NDK in this forum.

UnsatisfiedLinkError

Postby lord_ure » Tue Jun 15, 2010 8:12 am

Hi everybody, I'm working on the ndk provided by google and I have a problem with the first example provided by google :oops:
I can move my c file into a shared library *.so, but I can't use it in my application. To do it I have to load the library, but I have a UnsatisfiedLinkerror with the linen System.loadLibrary("hello-jni");

Here is my code :
Main.java :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.app.Activity;
  2. import android.widget.TextView;
  3. import android.os.Bundle;
  4.  
  5.  
  6. public class MainActivity extends Activity
  7. {
  8.     /** Called when the activity is first created. */
  9.     @Override
  10.     public void onCreate(Bundle savedInstanceState)
  11.     {
  12.         super.onCreate(savedInstanceState);
  13.  
  14.         TextView  tv = new TextView(this);
  15.         tv.setText( stringFromJNI() );
  16.         setContentView(tv);
  17.     }
  18.  
  19.     public native String  stringFromJNI();
  20.  
  21.     static {
  22.         System.loadLibrary("hello-jni"); //The Error occurs here
  23.     }
  24. }
  25.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Here is my c file :
Syntax: [ Download ] [ Hide ]
Using cpp Syntax Highlighting
  1. #include <string.h>
  2. #include <jni.h>
  3.  
  4. jstring
  5. Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
  6.                                                   jobject thiz )
  7. {
  8.     return (*env)->NewStringUTF(env, "Hello from JNI !");
  9. }
  10.  
Parsed in 0.005 seconds, using GeSHi 1.0.8.4

I am developping on netbeans 6.8 and windows seven

I have looked for solution on internet but I have found nothing, so if you have an idea.............

by 8)
Sorry for my english, I'm french ........ :(
lord_ure
Developer
Developer
 
Posts: 46
Joined: Fri Apr 16, 2010 4:29 pm
Location: Nancy, FRANCE

Top

Re: UnsatisfiedLinkError

Postby gskbyte » Tue Jun 15, 2010 4:13 pm

What do you have on your Android.mk file? Have a look at the other thread, it has an example that may be interesting.
gskbyte
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Tue Jan 12, 2010 1:51 pm

Re: UnsatisfiedLinkError

Postby lord_ure » Wed Jun 16, 2010 10:33 am

Hi, I have found the problem. It's pretty silly.
netbeans don't add the created library to the apk, that's all, I have to add a target in the build.xml of my netbeans project, but I don't know how to do that. So I have tried my code under eclipse and it works. Pretty silly :(

Thanks for answering.
By
Sorry for my english, I'm french ........ :(
lord_ure
Developer
Developer
 
Posts: 46
Joined: Fri Apr 16, 2010 4:29 pm
Location: Nancy, FRANCE

Re: UnsatisfiedLinkError

Postby aashishvijayvirgiya » Wed Jun 01, 2011 10:30 am

new to android.
working on android jni(ndk).done some sample projects based on prebuilt library, having same problems
my androi.mk is

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE :=hello-jni
LOCAL_SRC_FILE:=hello-jni.c
LOCAL_SHARED_LIBRARY := ndk
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := ndk
NDK_MODULE_PATH := $(LOCAL_PATH)
LOCAL_SRC_FILES := libndk.so
include $(PREBUILT_SHARED_LIBRARY)

hello-jni.c calls functions from libndk.so(ARM lib.)

this project run successfully several times but when i restarted the eclipse and again run the project from eclipse.
emulator load the project. but having the problem calling funtions from shared library. it stopped unexpectedly. when i debug in logcat view it show unsatisfied linker error.
please help me out this problem.
attached the project also

my email address is ashish_vijayvirgiya@yahoo.com
if you want some additional information then you tell me.

thanks.
aashishvijayvirgiya
Freshman
Freshman
 
Posts: 8
Joined: Tue May 31, 2011 8:30 am

Top

Return to NDK Problems

Who is online

Users browsing this forum: No registered users and 1 guest