How to unit test serial ports in Java on Android -


i'm aware android not provide out-of-the-box access serial ports unless device rooted or custom android version flashed, on beaglebone black board -- case. using android serialport api project able access , test serial ports of device through sample gui app (slightly modified).

however, i'd add junit tests serial api because expanding library module client programmers use. tried using androidtestcase, i'm receiving error:

java.lang.unsatisfiedlinkerror: native method not found:   com.xxx.android.serialport_api.serialport.open:   (ljava/lang/string;ii)ljava/io/filedescriptor; @ com.xxx.android.serialport_api.serialport.open(native  method) @ com.xxx.android.serialport_api.serialport.<init     (serialport.java:32) 

it seems me serialport.so files not loaded/visible inside mock environment provided androidtestcase. i'm using standard test structure created "new module" wizard in android studio.

any advice or hint appreciated because search on topic turned nothing out. i'll happy provide test class , implementation if needed (although implementation pretty same serialport.java class in open source sample referenced above).

i found issue. package name hardcoded in pre-compiled .so files. instead of using custom package name com.xxx.xxx 1 has put serialport (and other implementing classes) in top-level package directly under /java folder. package name should android_serialport_api -- in library sample.


Comments