求大神们指导
我的android JNI 不能用
我已经得到.so文件了,并且push到system\lib中了
但是在java中调用不行啊,模拟器打开程序就崩溃了我是用ndk编译出来.so
然后用eclipse 建工程添加的
这会不会不行呢?
java
public class JNITestActivity extends Activity { private TextView t;
static
{
System.loadLibrary("JNITest");
}
    public native String stringFromJNI();
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     String msg = stringFromJNI();
     t = (TextView)findViewById(R.id.y);
     t.setText(msg);
        //System.out.println(msg);
        
    }
}c#include <string.h>
#include <jni.h>/* This is a trivial JNI example where we use a native method
 * to return a new VM String. See the corresponding Java source
 * file located at:
 *
 *   apps/samples/hello-jni/project/src/com/example/HelloJni/HelloJni.java
 */
JNIEXPORT jstring JNICALL Java_com_hjy_jni_JNITest_stringFromJNI( JNIEnv* env, jobject thiz )
{
    return (*env)->NewStringUTF(env, "Hello from JNI !");
}

解决方案 »

  1.   

    你的so为啥要放到system\lib下面? 
      

  2.   

     static {
         try{
         System.loadLibrary("JNITest");
         }catch(UnsatisfiedLinkError e)
         {
         System.err.println( "Cannot load hello library:\n " + e.toString() ); 
         }
        }看加载成功没,若加载成功,则在jni接口处下断点看是不是该接口的调用问题
      

  3.   

    注意包名类名方法名。
    Java_com_hjy_jni_JNITest_stringFromJNIcom.hjy.jni 你的包名
    JNITest 你的类名
    stringFromJNI 你的方法名.so放到libs/armeabi/下