Add .so files to Cordova Plugin

醉酒当歌 提交于 2019-12-11 04:27:13

问题


I have developed a Cordova Plugin for my Ionic app, which throws the following error when accessed:

java.lang.UnstatisfiedLinkError: dalvik.system.PathClassLoader [DexPathList [[zip file "/data/app/io.ionic.starter-2/base.apk"], nativeLibraryDirectories=[/data/app/io.ionic.starter-2/lib/arm/, /vendor/lib, /system/lib]]] couldn't find "libserial_port.so"

I've put libserial_port.so file in the libs folder, at this path: pluginName\src\android\libs\armeabi\libserial_port.so.

Then, in plugin.xml I've tried to load it both as a resource file:

<resource-file src="src/android/libs/armeabi/libserial_port.so" target="src/android/libs"/>

and as a lib-file:

<lib-file src="src/android/libs/armeabi/libserial_port.so" />

However, the error still appears. What shall I do for the app to see that library?


回答1:


I am able to resolve this issue by renaming libs to jniLibs.

Change

<resource-file src="src/android/libs/armeabi/libserial_port.so" target="libs/armeabi/libserial_port.so">

to

<resource-file src="src/android/libs/armeabi/libserial_port.so" target="jniLibs/armeabi/libserial_port.so">

also read my answer with similar issue Unable to run Android app after updating to cordova android 7.0.0



来源:https://stackoverflow.com/questions/48665656/add-so-files-to-cordova-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!