简体   繁体   中英

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "srand" referenced by "xx.so"

I am new to NDK develop. I have used NDK to generate xxx.so files and it works fine on Android 5.0 or above however it crash on Android 4.4 or pre.

Log is:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "srand" referenced by "xx.so"... at java.lang.Runtime.loadLibrary(Runtime.java:362) at java.lang.System.loadLibrary(System.java:525) at com.uniquestudio.lowpoly.LowPoly.(LowPoly.java:14) at com.uniquestudio.lowpolyandroid.MainActivity.onCreate(MainActivity.java:22) at android.app.Activity.performCreate(Activity.java:5372) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) at android.app.ActivityThread.access$700(ActivityThread.java:159) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5419) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect. Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) at dalvik.system.NativeStart.main(Native Method)

As Dan pointed it out in comments, your problem certainly comes from compiling against an android api level >=21.

To solve your issue, you can compile your code against the same platform than your APK's minSdkVersion .

How are you using the NDK? If you're using ndk-build , add an Application.mk file next to your Android.mk file, with for content APP_PLATFORM:=android-14 (where 14 is your minSdkVersion).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM