Android JNI 应用实例
2010-02-24 05:14:00 来源:WEB开发网# adb remount
# adb push out/target/product/generic/system/lib/libhello.so /system/lib
# adb install TestHelloLib.apk
接下来在模拟器菜单中可以看到已经安装的TestHelloLib程序,运行即可。
由于JNI接口printHello()并没有作界面上的改动,要验证其效果需要用Android的logcat工具来查看。运行”adb logcat”可以找到下面的log片断:
I/ActivityManager( 48): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x10200000 comp={com.test/com.test.TestHelloLib} }
I/ActivityManager( 48): Start proc com.test for activity com.test/.TestHelloLib: pid=174 uid=10024 gids={}
D/dalvikvm( 174): Trying to load lib /system/lib/libhello.so 0x43481c58
D/dalvikvm( 174): Added shared lib /system/lib/libhello.so 0x43481c58
D/dalvikvm( 174): No JNI_OnLoad found in /system/lib/libhello.so 0x43481c58
D/dalvikvm( 174): +++ not scanning '/system/lib/libwebcore.so' for 'printHello' (wrong CL)
D/dalvikvm( 174): +++ not scanning '/system/lib/libmedia_jni.so' for 'printHello' (wrong CL)
D/TestLib ( 174): Hello LIB!
I/ActivityManager( 48): Displayed activity com.test/.TestHelloLib: 806 ms
这里包含了调用printHello()接口的log信息,其中”D/TestLib ( 174): Hello LIB!”就是printHello()所打印的信息。至此成功完成Android JNI的实例验证。
更多精彩
赞助商链接