[libaryloader] synchronise access to the library loader load method (#58)
This commit is contained in:
@@ -5,7 +5,7 @@ import com.mapbox.mapboxsdk.log.Logger;
|
||||
/**
|
||||
* Loads the mapbox-gl shared library
|
||||
* <p>
|
||||
* By default uses the {@link System#loadLibrary(String)},
|
||||
* By default uses SoLoader from https://github.com/facebook/SoLoader
|
||||
* use {@link #setLibraryLoader(LibraryLoader)} to provide an alternative library loading hook.
|
||||
* </p>
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ public abstract class LibraryLoader {
|
||||
* Catches UnsatisfiedLinkErrors and prints a warning to logcat.
|
||||
* </p>
|
||||
*/
|
||||
public static void load() {
|
||||
public static synchronized void load() {
|
||||
try {
|
||||
if (!loaded) {
|
||||
loaded = true;
|
||||
|
||||
@@ -12,7 +12,7 @@ import static com.facebook.soloader.SoLoader.loadLibrary;
|
||||
/**
|
||||
* Concrete implementation of a native library loader.
|
||||
* <p>
|
||||
* Uses ReLinker from https://github.com/KeepSafe/ReLinker.
|
||||
* Uses SoLoader from https://github.com/facebook/SoLoader.
|
||||
* </p>
|
||||
*/
|
||||
public class LibraryLoaderProviderImpl implements LibraryLoaderProvider {
|
||||
@@ -28,7 +28,7 @@ public class LibraryLoaderProviderImpl implements LibraryLoaderProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Concrete implementation of a LibraryLoader using ReLinker.
|
||||
* Concrete implementation of a LibraryLoader using SoLoader.
|
||||
*/
|
||||
private static class SoLibraryLoader extends LibraryLoader {
|
||||
|
||||
@@ -43,6 +43,7 @@ public class LibraryLoaderProviderImpl implements LibraryLoaderProvider {
|
||||
} catch (MapboxConfigurationException exception) {
|
||||
Logger.e(TAG, "Couldn't load so file with relinker, application context missing, "
|
||||
+ "call Mapbox.getInstance(Context context, String accessToken) first");
|
||||
throw new UnsatisfiedLinkError(exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user