Does nativescript supports .so file in android platform?

為{幸葍}努か 提交于 2019-11-28 08:51:47

问题


Recently we are using nativescript to build an app, and we need to use a third-patty library which provides both IOS and Android SDK. But it failed even we push .so file to lib folder, the error is the library cannot find the expected .so file during app running.
So I want to know does nativescript supports .so file and how to make it works? Thanks in advance.


回答1:


Currently this task is not automated in the tns CLI but it should be possible to copy your *.so files in <project>/platforms/android/libs/jni/armeabi-v7a and/or <project>/platforms/android/libs/jni/x86 directories. Gradle build respects these folders and *.so files will be included in the *.apk package.




回答2:


A better way to push .so files and .jar files together, is to repackage them as an .aar file, using Android Studio. Then copy the wrapper .aar file to your nativescirpt platform/android/libs folder.

Here are the steps to package your SDK .jar and .so files into an aar file.

  1. Create an application with blank activity in Android Studio.
  2. Create a new wrapper module yoursdkwrapper (New->New Module->Android Library).
  3. Copy your SDK .jar files to MyApplication\yoursdkwrapper\libs folder.
  4. Under your MyApplication\yoursdkwrapper\src\main\ folder, create the following directory structure and copy .so files to each of architecture folders: jniLibs/arm64-v8a, jniLibs/armeabi, jniLibs/armeabi-v7a, jniLibs/x86.
  5. yoursdkwrapper-debug.aar file will be generated in your MyApplication\epos2wrapper\build\outputs\aar.



回答3:


addition to for Karthik Sankar's answer. my *.so files got copied to app but did not get referenced.

In this case you need to manually reference all of them like this. java.lang.System.loadLibrary("avcodec");

to check if *.so files get copied use Native Libs Monitor app.

ReLinker might be helpful too

for detail https://github.com/bytedeco/javacpp-presets/issues/303



来源:https://stackoverflow.com/questions/33737385/does-nativescript-supports-so-file-in-android-platform

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