# LibraryLoader

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/LibraryLoader.java+class:androidx.media3.common.util.LibraryLoader)

*** ** * ** ***


```
@UnstableApi
public abstract class LibraryLoader
```

<br />

*** ** * ** ***

Configurable loader for native libraries.

## Summary

| ### Public fields |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/util/LibraryLoader#isAvailable()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/util/LibraryLoader#LibraryLoader(java.lang.String...)(String[] libraries)` |

| ### Public methods |
|---|---|
| `synchronized boolean` | `https://developer.android.com/reference/androidx/media3/common/util/LibraryLoader#isAvailable()()` Returns whether the underlying libraries are available, loading them if necessary. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/common/util/LibraryLoader#setLibraries(java.lang.String...)(String[] libraries)` Overrides the names of the libraries to load. |

| ### Protected methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/common/util/LibraryLoader#loadLibrary(java.lang.String)(https://developer.android.com/reference/java/lang/String.html name)` Should be implemented to call `System.loadLibrary(name)`. |

## Public fields

### isAvailable

```
public boolean isAvailable
```

## Public constructors

### LibraryLoader

```
public LibraryLoader(String[] libraries)
```

| Parameters |
|---|---|
| `String[] libraries` | The names of the libraries to load. |

## Public methods

### isAvailable

```
synchronized public boolean isAvailable()
```

Returns whether the underlying libraries are available, loading them if necessary.

### setLibraries

```
synchronized public void setLibraries(String[] libraries)
```

Overrides the names of the libraries to load. Must be called before any call to `https://developer.android.com/reference/androidx/media3/common/util/LibraryLoader#isAvailable()`.

## Protected methods

### loadLibrary

```
protected abstract void loadLibrary(String name)
```

Should be implemented to call `System.loadLibrary(name)`.

It's necessary for each subclass to implement this method because `https://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)` uses reflection to obtain the calling class, which is then used to obtain the class loader to use when loading the native library. If this class were to implement the method directly, and if a subclass were to have a different class loader, then loading of the native library would fail.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html name` | The name of the library to load. |