加载本机库时出现不满意的链接错误

时间:2013-12-20 06:14:20

标签: android java-native-interface unsatisfiedlinkerror

启动应用程序后,我在加载本机库时遇到此不满意的链接错误。编译本机代码时没有显示任何错误。在logcat中它说“无法从loader dalvik.system.PathClassLoader加载testwork,findLibrary返回null。但是libs / armeabi中有testwork库。我在NativeClass.java中的静态块中加载库。

这是我的mainactivity.java

package com.pkg.netwrokinnative;

import java.net.Socket;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity {

    private Socket client;

     private EditText textField1;
     private Button button;
     private String messsage;
     private NativeClass nativeobj;

     @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      textField1 = (EditText) findViewById(R.id.editText1); //reference to the text field
      button = (Button) findViewById(R.id.button1);   //reference to the send button
      nativeobj = new NativeClass();
      //Button press event listener 
      button.setOnClickListener(new View.OnClickListener() {

       public void onClick(View v) {           
          Context context = getApplicationContext();
          CharSequence text = "Hello toast!";
          int duration = Toast.LENGTH_SHORT;
          Toast toast = Toast.makeText(context, text, duration);
          toast.show();
          messsage = textField1.getText().toString(); //get the text message on the text field      
          textField1.setText(""); 
          messsage = nativeobj.callClient(messsage);
          textField1.setText(messsage);
       }});
     }
}

0 个答案:

没有答案