inin
inin

Reputation: 382

NDK UnsatisfiedLinkError when lowering project api level 21 to 19

I made project using ndk with api level 21. But some reasons, I downgraded project api level 21 to 19.

My project worked fine in api 21, But after downgrading my project gives error in NDK part.

This is my error code when my project runs System.loadLibrary("serial_port");.

AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "tcgetattr" referenced by "libserial_port.so"...
AndroidRuntime:     at java.lang.Runtime.loadLibrary(Runtime.java:364)
AndroidRuntime:     at java.lang.System.loadLibrary(System.java:526)
AndroidRuntime:     at com.josh.mainSelection.UartUI.onCreate(UartUI.java:220)
AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5231)
AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:135)
AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
AndroidRuntime:     at android.os.Looper.loop(Looper.java:136)
AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5001)
AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:811)
AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:627)
AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)

I'm first using NDK, and I'm not able to figure the problem. please help me solving error.

I'm using gradle-experimental:0.4.0.

Upvotes: 2

Views: 1505

Answers (2)

jp1017
jp1017

Reputation: 81

This made me crazy.

my compileSdkVersion 23

But I solve it just now.

You can see the diff of termios.h file between API 19 and 21+.

so, I copy the termios.h from D:\Android\Sdk\ndk-bundle\platforms\android-19\arch-arm\usr\include to jni folder, and then it works.

Upvotes: 3

inin
inin

Reputation: 382

I don't know why it works. But after deleting all .so files in my project and rebuilding, It works without any errors. I think .so files made in api level-21 made a crash someway.

Upvotes: 0

Related Questions