0

I have a problem and I didn't find the mistake, here is my MainActivity code:

public class MainActivity extends Activity {

    private static final String TAG = "odroid_weather";
    private double temp1, temp2, pressure, altitude, humidity, uv;
    private int visible, ir;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.weatherBoardTest();
        TextView tv = new TextView(this);
        tv.setText(Afficher());
        setContentView(tv);
        TextView temp = new TextView(this);
        temp.setText((int) this.getTemperature1());
        setContentView(temp);
    }

    static
    {
        System.loadLibrary("libodroid_weather");
    }

    public double getTemperature1() {
        return temp1;
    }
    public double getTemperature2() {
        return temp2;
    }

    public double getPressure() {
        return pressure;
    }

    public double getHumidity() {
        return humidity;
    }

    public double getAltitude() {
        return altitude;
    }

           public double getUV() {
        return uv;
    }

    public int getVisibleLight() {
        return visible;
    }

    public int getInfrared() {
        return ir;
    }

    private native String Afficher();


    public native void initSerialInterface();

    public native void readData();
    public native void close();
    static
    {
        System.loadLibrary("odroid_weather");
    }
    protected void weatherBoardTest() {
        Log.d(TAG, "testing weather board");
        initSerialInterface();
        readData();
        Log.d(TAG, "temperature1 = "+this.getTemperature1());
        Log.d(TAG, "Now closing file descriptor.");
       ///  close();
        Log.d(TAG, "finished!");
    }

and the this is the cpp code for these native methods:

extern "C" {
    void  Java_com_example_assus_appweather_MainActivity_initSerialInterface(){
        initSerial();
    }

    void Java_com_example_assus_appweather_MainActivity_close() {
        close(fd);
    }

    void Java_com_example_assus_appweather_MainActivity_readData(JNIEnv* env, jobject thiz) {
        LOGD("readData()");

I can't find where is the mistake: cannot responding JNI fonctions com.assus.appweather.MainActivity

Cœur
  • 37,241
  • 25
  • 195
  • 267
ahmed
  • 1
  • 1. Copy what the exception really says. 2. Calling both `System.loadLibrary("libodroid_weather");` and `System.loadLibrary("odroid_weather");` definitely won't work. (The latter is the only correct one.) – StenSoft Apr 04 '16 at 20:15
  • that what the exeption really says : that what the exeption really says : * java.lang.UnsatisfiedLinkError: Couldn't load odroid_weather from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.assus.weatherapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.assus.weatherapp-2, /vendor/lib, /system/lib]]]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java:358) at java.lang.System.loadLibrary(System.java:526) – ahmed Apr 06 '16 at 08:28
  • Improve code formatting – derekerdmann Apr 06 '16 at 19:11

0 Answers0