添加so文件到代码codenameone到本机android?

时间:2017-10-29 11:51:15

标签: android android-ndk native codenameone manifest

我正在研究一些新的本机包以使用某些特殊设备,并且使用的库是(so)文件,如果有人可以帮我弄清楚如何在android版本中包含这些文件,我将不胜感激,I尝试添加本机android文件夹中的文件,但在尝试从本机调用该函数时,会显示以下异常:

10-29 14:10:07.610: D/BarcodeManager(6466): Barcode_Start()
10-29 14:10:07.610: W/System.err(6466): WARNING: Could not load library!
10-29 14:10:07.610: I/info(6466): error ===  Couldn't load Jctrl_gpio: findLibrary returned null
10-29 14:10:07.610: W/dalvikvm(6466): No implementation found for native Lcom/ctrl/gpio/Ioctl;.activate:(II)I
10-29 14:10:07.610: D/AndroidRuntime(6466): Shutting down VM
10-29 14:10:07.610: W/dalvikvm(6466): threadid=1: thread exiting with uncaught exception (group=0x41cd5300)
10-29 14:10:07.620: E/AndroidRuntime(6466): FATAL EXCEPTION: main
10-29 14:10:07.620: E/AndroidRuntime(6466): java.lang.UnsatisfiedLinkError: Native method not found: com.ctrl.gpio.Ioctl.activate:(II)I
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.ctrl.gpio.Ioctl.activate(Native Method)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.POSD.controllers.ScanController.doScan(ScanController.java:715)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.POSD.controllers.ScanController.scan(ScanController.java:706)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.POSD.controllers.ScanController.Barcode_Start(ScanController.java:461)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.mycompany.myapp.NativePrinterImpl$ScanActivity.readBarCode(NativePrinterImpl.java:90)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.mycompany.myapp.NativePrinterImpl$ScanActivity.<init>(NativePrinterImpl.java:37)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.mycompany.myapp.NativePrinterImpl$1.run(NativePrinterImpl.java:130)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at android.os.Handler.handleCallback(Handler.java:615)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at android.os.Looper.loop(Looper.java:137)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at android.app.ActivityThread.main(ActivityThread.java:4745)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at java.lang.reflect.Method.invokeNative(Native Method)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at java.lang.reflect.Method.invoke(Method.java:511)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-29 14:10:07.620: E/AndroidRuntime(6466):     at dalvik.system.NativeStart.main(Native Method)
10-29 14:10:07.620: W/ActivityManager(272):   Force finishing activity com.mycompany.myapp/.MyApplicationStub
10-29 14:10:08.160: W/ActivityManager(272): Activity pause timeout for ActivityRecord{42681788 com.mycompany.myapp/.MyApplicationStub}

我正在添加硬件日志中包含的本机应用程序:

10-29 17:22:55.990 272-301/system_process I/ActivityManager: Displayed com.POS.apis/.ApiDemosMainActivity: +804ms
10-29 17:22:56.960 272-10680/system_process I/ActivityManager: START {cmp=com.POS.apis/.ScanController.ScanActivity u=0} from pid 11196
10-29 17:22:57.060 272-10680/system_process D/dalvikvm: GC_FOR_ALLOC freed 91K, 15% free 9728K/11399K, paused 31ms, total 31ms
10-29 17:22:57.060 272-10680/system_process I/dalvikvm-heap: Grow heap (frag case) to 9.908MB for 124216-byte allocation
10-29 17:22:57.090 272-10680/system_process D/dalvikvm: GC_FOR_ALLOC freed 5K, 15% free 9844K/11527K, paused 29ms, total 29ms
10-29 17:22:57.140 11196-11200/com.POS.apis D/dalvikvm: GC_CONCURRENT freed 887K, 15% free 8127K/9479K, paused 11ms+11ms, total 33ms
10-29 17:22:57.190 100-247/? I/AwesomePlayer: AwesomePlayer::AwesomePlayer()in
10-29 17:22:57.190 100-247/? I/AwesomePlayer: AwesomePlayer::AwesomePlayer()aftermClient.connect()
10-29 17:22:57.240 100-247/? I/FrameQueueManage: FrameQueueManage::~FrameQueueManage end!
10-29 17:22:57.290 272-301/system_process I/ActivityManager: Displayed com.POS.apis/.ScanController.ScanActivity: +192ms
10-29 17:22:58.270 100-246/? D/AudioHardware: AudioHardware pcm playback is going to standby.
10-29 17:22:58.270 100-246/? D/AudioHardware: closePcmOut_l() mPcmOpenCnt: 1
10-29 17:22:58.300 100-246/? D/AudioHardware: AudioHardware pcm playback is exiting standby.
10-29 17:22:58.300 100-246/? D/AudioHardware: openPcmOut_l() mPcmOpenCnt: 0
10-29 17:22:58.310 11196-11196/com.POS.apis D/dalvikvm: Trying to load lib /data/data/com.POS.apis/lib/libJctrl_gpio.so 0x422fcf58
10-29 17:22:58.310 11196-11196/com.POS.apis D/dalvikvm: Added shared lib /data/data/com.POS.apis/lib/libJctrl_gpio.so 0x422fcf58
10-29 17:22:58.310 11196-11196/com.POS.apis I/ctrl_gpio: JNI_OnLoad
10-29 17:22:58.310 11196-11196/com.POS.apis I/ctrl_gpio: native_activate fd=49,type=17,open=0
10-29 17:22:58.310 11196-11196/com.POS.apis I/ctrl_gpio: ret-------------0
10-29 17:22:58.310 11196-11196/com.POS.apis D/dalvikvm: Trying to load lib /data/data/com.POS.apis/lib/libserialport.so 0x422fcf58
10-29 17:22:58.310 11196-11196/com.POS.apis D/dalvikvm: Added shared lib /data/data/com.POS.apis/lib/libserialport.so 0x422fcf58
10-29 17:22:58.310 11196-11196/com.POS.apis D/dalvikvm: No JNI_OnLoad found in /data/data/com.POS.apis/lib/libserialport.so 0x422fcf58, skipping init
10-29 17:22:58.310 11196-11196/com.POS.apis D/serial_port: Opening serial port /dev/ttyS1 with flags 0x2
10-29 17:22:58.310 11196-11196/com.POS.apis D/serial_port: open() fd = 51
10-29 17:22:58.310 11196-11196/com.POS.apis I/info: open device!!
10-29 17:23:00.560 1997-1999/com.wandoujia.phoenix2.usbproxy D/dalvikvm: GC_CONCURRENT freed 1233K, 39% free 9973K/16135K, paused 2ms+3ms, total 66ms
10-29 17:23:01.320 100-246/? D/AudioHardware: AudioHardware pcm playback is going to standby.
10-29 17:23:01.320 100-246/? D/AudioHardware: closePcmOut_l() mPcmOpenCnt: 1
10-29 17:23:13.180 100-246/? D/AudioHardware: AudioHardware pcm playback is exiting standby.
10-29 17:23:13.180 100-246/? D/AudioHardware: openPcmOut_l() mPcmOpenCnt: 0

因为您可以看到加载so文件并且应用程序正常工作没有问题

此致

1 个答案:

答案 0 :(得分:0)

只需将文件放在项目Android文件夹的native文件夹中,您就可以在原生源代码中使用它。