Unit test Java class that loads native library

前端 未结 8 631
自闭症患者
自闭症患者 2021-02-01 11:49

I\'m running unit tests in Android Studio. I have a Java class that loads a native library with the following code

 static
    {
       System.loadLibrary(\"myli         


        
8条回答
  •  无人共我
    2021-02-01 12:31

    Just make sure, the directory containing the library is contained in the java.library.path system property.

    From the test you could set it before you load the library:

    System.setProperty("java.library.path", "... path to the library .../libs/x86");
    

    You can specify the path hard coded, but this will make the project less portable to other environments. So I suggest you build it up programmatically.

提交回复
热议问题