游戏编译的时候不报错,运行的时候报了如下的错误:
(主要是Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "libgameshared.so"...)
10-31 12:35:59.667: D/dalvikvm(5657): Trying to load lib /data/app-lib/net.shanggame.pantheon-1/libgameshared.so 0x417c27e8
10-31 12:35:59.674: E/dalvikvm(5657): dlopen("/data/app-lib/net.shanggame.pantheon-1/libgameshared.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "libgameshared.so"...
10-31 12:35:59.674: W/dalvikvm(5657): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lnet/shanggame/pantheon/GameActivity;
10-31 12:35:59.674: W/dalvikvm(5657): Class init failed in newInstance call (Lnet/shanggame/pantheon/GameActivity;)
10-31 12:35:59.674: D/AndroidRuntime(5657): Shutting down VM
10-31 12:35:59.674: W/dalvikvm(5657): threadid=1: thread exiting with uncaught exception (group=0x40cef930)
10-31 12:35:59.680: E/AndroidRuntime(5657): FATAL EXCEPTION: main
10-31 12:35:59.680: E/AndroidRuntime(5657): java.lang.ExceptionInInitializerError
10-31 12:35:59.680: E/AndroidRuntime(5657): at java.lang.Class.newInstanceImpl(Native Method)
10-31 12:35:59.680: E/AndroidRuntime(5657): at java.lang.Class.newInstance(Class.java:1319)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.app.Instrumentation.newActivity(Instrumentation.java:1057)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2115)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.app.ActivityThread.access$600(ActivityThread.java:145)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.os.Handler.dispatchMessage(Handler.java:99)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.os.Looper.loop(Looper.java:137)
10-31 12:35:59.680: E/AndroidRuntime(5657): at android.app.ActivityThread.main(ActivityThread.java:5095)
10-31 12:35:59.680: E/AndroidRuntime(5657): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 12:35:59.680: E/AndroidRuntime(5657): at java.lang.reflect.Method.invoke(Method.java:511)
10-31 12:35:59.680: E/AndroidRuntime(5657): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
10-31 12:35:59.680: E/AndroidRuntime(5657): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
10-31 12:35:59.680: E/AndroidRuntime(5657): at dalvik.system.NativeStart.main(Native Method)
10-31 12:35:59.680: E/AndroidRuntime(5657): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "libgameshared.so"...
10-31 12:35:59.680: E/AndroidRuntime(5657): at java.lang.Runtime.loadLibrary(Runtime.java:371)
10-31 12:35:59.680: E/AndroidRuntime(5657): at java.lang.System.loadLibrary(System.java:535)
10-31 12:35:59.680: E/AndroidRuntime(5657): at net.shanggame.pantheon.GameActivity.<clinit>(GameActivity.java:35)
10-31 12:35:59.680: E/AndroidRuntime(5657): ... 15 more
根据错误来看,原因是由于程序不能正确的调用rand函数导致的,而不能正确调用的原因是因为ndk的版本过高,不兼容导致的。