Reputation: 1047
I am trying to integrate the Android SerialPort API into my project, but I have some problems doing so.
Eclipse is not resolving all JNI and native related methods and fields.. This is the beginning of the SerialPort.c file of the Android SerialPort API:
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <jni.h>
#include "SerialPort.h"
#include "android/log.h"
static const char *TAG="serial_port";
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##args)
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
The fist define-statement works, but in the other two, eclipse is
marking ANDROID_LOG_DEBUG
and ANDROID_LOG_ERROR
with Symbol XXX
could not be resolved
, as well as every call of a method of JNIEnv
*env
inside the methods of the serial port.
But there are no errors on the JNIEXPORT or JNICALL statements.
Problem one occured when I was trying to solve this problem. I downloaded all files for library and copied them in the directories given on the website. But it seems that something went wrong with the JNI part and I was not able to call open()
to get my serial device.
11-19 14:18:22.232: D/dalvikvm(17898): Trying to load lib /data/data/master.androidsirfparser/lib/libserial_port.so 0x416a8570
11-19 14:18:22.232: D/dalvikvm(17898): Added shared lib /data/data/master.androidsirfparser/lib/libserial_port.so 0x416a8570
11-19 14:18:22.232: D/dalvikvm(17898): No JNI_OnLoad found in /data/data/master.androidsirfparser/lib/libserial_port.so 0x416a8570, skipping init
11-19 14:18:22.232: W/dalvikvm(17898): No implementation found for native Lmaster/serial/SerialPort;.open (Ljava/lang/String;II)Ljava/io/FileDescriptor;
11-19 14:18:22.240: W/dalvikvm(17898): threadid=11: thread exiting with uncaught exception (group=0x40a471f8)
11-19 14:18:22.240: E/AndroidRuntime(17898): FATAL EXCEPTION: Thread-651
11-19 14:18:22.240: E/AndroidRuntime(17898): java.lang.UnsatisfiedLinkError: open
11-19 14:18:22.240: E/AndroidRuntime(17898): at master.serial.SerialPort.open(Native Method)
11-19 14:18:22.240: E/AndroidRuntime(17898): at master.serial.SerialPort.<init>(SerialPort.java:61)
11-19 14:18:22.240: E/AndroidRuntime(17898): at master.androidsirfparser.ReadThread.init(ReadThread.java:38)
11-19 14:18:22.240: E/AndroidRuntime(17898): at master.androidsirfparser.ReadThread.run(ReadThread.java:48)
I always get the "no implementation found"-message.
I have to solve problem one first, in order to work on problem two, because Eclipse does not allow me to start my project without solving the compilation error in the code.
Upvotes: 4
Views: 2176
Reputation: 1047
I re-installed my java platform, eclipse IDE, added the android eclipse plugin and now it works. I have no clue why.
Upvotes: 3