问题
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