Class NativeLoader

java.lang.Object
com.facebook.soloader.nativeloader.NativeLoader

public class NativeLoader extends Object
Facade to load native libraries for android
  • Method Details

    • loadLibrary

      public static boolean loadLibrary(String shortName)
    • loadLibrary

      public static boolean loadLibrary(String shortName, int flags)
      Load a shared library, initializing any JNI binding it contains. Depending upon underlying loader, behavior can be customized based on passed in flag
      Parameters:
      shortName - Name of library to find, without "lib" prefix or ".so" suffix
      flags - 0 for default behavior, otherwise NativeLoaderDelegate defines other behaviors.
      Returns:
      Whether the library was loaded as a result of this call (true), or was already loaded through a previous call (false).
    • getLibraryPath

      public static String getLibraryPath(String shortName) throws IOException
      Get the path of a loaded shared library.
      Parameters:
      shortName - Name of library to find, without "lib" prefix or ".so" suffix
      Returns:
      The path for the loaded library, null otherwise.
      Throws:
      IOException - IOException
    • getSoSourcesVersion

      public static int getSoSourcesVersion()
      Get the version of the loader used.
      Returns:
      The version number for the loader.
    • init

      public static void init(NativeLoaderDelegate delegate)
      Initializes native code loading for this app. Should be called only once, before any calls to loadLibrary(String).
      Parameters:
      delegate - Delegate to use for all loadLibrary calls.
    • isInitialized

      public static boolean isInitialized()
      Determine whether NativeLoader has already been initialized. This method should not normally be used, because initialization should be performed only once during app startup. However, libraries that want to provide a default initialization for NativeLoader to hide its existence from the app can use this method to avoid re-initializing.
      Returns:
      True if init(NativeLoaderDelegate) has been called.
    • initIfUninitialized

      public static void initIfUninitialized(NativeLoaderDelegate delegate)
      Perform an initialization only if NativeLoader has not already been initialized. This protects against race conditions where isInitialized and init are called by multiple threads and both threads end up trying to perform an initialization
      Parameters:
      delegate - the NativeLoaderDelegate