添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接


测试一程序显示:


</pre><pre name="code" class="cpp">07-02 14:26:33.950: E/AndroidRuntime(18515): FATAL EXCEPTION: main
07-02 14:26:33.950: E/AndroidRuntime(18515): java.lang.ExceptionInInitializerError
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at com.example.hellondk.MainActivity.<init>(MainActivity.java:9)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at java.lang.Class.newInstanceImpl(Native Method)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at java.lang.Class.newInstance(Class.java:1319)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.app.ActivityThread.access$600(ActivityThread.java:144)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.os.Looper.loop(Looper.java:152)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at android.app.ActivityThread.main(ActivityThread.java:5132)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at java.lang.reflect.Method.invoke(Method.java:511)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at dalvik.system.NativeStart.main(Native Method)
07-02 14:26:33.950: E/AndroidRuntime(18515): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libgnustl_shared.so" needed by "libhello-jni.so"; caused by load_library(linker.cpp:745): library "libgnustl_shared.so" not found
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at java.lang.Runtime.loadLibrary(Runtime.java:371)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at java.lang.System.loadLibrary(System.java:535)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	at com.example.hellondk.NDKtest.<clinit>(NDKtest.java:16)
07-02 14:26:33.950: E/AndroidRuntime(18515): 	... 16 more
07-02 14:38:59.580: E/dalvikvm(19979): dlopen("/data/app-lib/com.example.hellondk-1/libhello-jni.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libstlport_shared.so" needed by "libhello-jni.so"; caused by load_library(linker.cpp:761): not a valid ELF executable: libstlport_shared.so
07-02 14:39:04.840: W/dalvikvm(19979): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/hellondk/NDKtest;
07-02 14:39:07.260: D/AndroidRuntime(19979): Shutting down VM
07-02 14:39:07.260: W/dalvikvm(19979): threadid=1: thread exiting with uncaught exception (group=0x419b7e10)
07-02 14:39:07.280: E/AndroidRuntime(19979): FATAL EXCEPTION: main
07-02 14:39:07.280: E/AndroidRuntime(19979): java.lang.ExceptionInInitializerError
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at com.example.hellondk.MainActivity.onCreate(MainActivity.java:13)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.Activity.performCreate(Activity.java:5104)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2227)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.ActivityThread.access$600(ActivityThread.java:144)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.os.Looper.loop(Looper.java:152)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at android.app.ActivityThread.main(ActivityThread.java:5132)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at java.lang.reflect.Method.invoke(Method.java:511)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at dalvik.system.NativeStart.main(Native Method)
07-02 14:39:07.280: E/AndroidRuntime(19979): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libstlport_shared.so" needed by "libhello-jni.so"; caused by load_library(linker.cpp:761): not a valid ELF executable: libstlport_shared.so
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at java.lang.Runtime.loadLibrary(Runtime.java:371)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at java.lang.System.loadLibrary(System.java:535)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	at com.example.hellondk.NDKtest.<clinit>(NDKtest.java:16)
07-02 14:39:07.280: E/AndroidRuntime(19979): 	... 15 more


解决方法:

查看原项目Application.mk

发现

APP_STL :=  gnustl_shared

APP_STL 可用值
system  系统默认
stlport_static - 使用STLport作为静态库
stlport_shared - 使用STLport 作为共享库
gnustl_static  -  使用GNU libstdc++ 作为静态库
gnustl_shared -  使用GNU libstdc++ 作为共享库


原方案使用的是共享库,这不一定都支持所有的机型,改用静态库gnustl_static  问题解决。

configure: error: readline library not found/libreadline.so: undefined reference to tputs

编译时显示错误:configure: error: readline library not found确定编译readline​看看config.log:configure:11829: gcc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wen