gpt4 book ai didi

android - 将so文件添加到代码codenameone到原生android?

转载 作者:行者123 更新时间:2023-11-29 02:36:10 28 4
gpt4 key购买 nike

我正在开发一些新的 native 包以与某些特殊设备一起使用,并且使用的库是(so)文件,如果有人可以帮助我弄清楚如何将这些文件包含在 android 构建中,我将不胜感激,我已尝试将文件添加到 native android 文件夹中,但是当尝试从 native 调用该函数时,显示以下异常:

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}

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

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 文件没有问题,应用程序可以正常工作

问候,

最佳答案

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

关于android - 将so文件添加到代码codenameone到原生android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46999823/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com