Using existing shared library (.so) in Android application

后端 未结 2 2019
攒了一身酷
攒了一身酷 2021-02-08 12:23

I have the follow scenario to work on. I was given a shared library (libeffect.so) to use in a Android project i am working for a client. I dont have the shared library source c

2条回答
  •  一向
    一向 (楼主)
    2021-02-08 13:12

    1. Do I need to place the native method signature in the same package/class as those defined when the .so was or I can use this signature in any package/class in my project that during runtime the jvm will be able to find the method in the shared library? For example, if this shared library was firstly used in a class mypackage.MyClass, do I need to create the same package, class and then put the method signature there?

    No need to create same package/class. You can put the method signature in any package.

    public class NativeLib {
    
      static {
        System.loadLibrary("so_file");
      }
    
      public static native void doEffect(int param1, IntBuffer intBuffer);
    
    }
    

    2.Where do I need to place this .so file inside my eclipse android project to get this file deployed inside my apk file?

    You have put this .so file in lib folder of your application . IF lib folder is not there then you can create a lib folder and put the .so file. you can call it by using System.loadLibrary("so_ file");

提交回复
热议问题