Disable UnsatisfiedLinkError during local tests (#3942)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.maplibre.android;
|
||||
|
||||
import org.maplibre.android.log.Logger;
|
||||
import org.maplibre.android.utils.PlatformUtils;
|
||||
|
||||
/**
|
||||
* Loads the mapbox-gl shared library
|
||||
@@ -56,7 +57,7 @@ public abstract class LibraryLoader {
|
||||
Logger.e(TAG, message, error);
|
||||
MapStrictMode.strictModeViolation(message, error);
|
||||
|
||||
if (!handleLoadError) {
|
||||
if (!handleLoadError && !PlatformUtils.isTest()) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.maplibre.android.utils;
|
||||
|
||||
public class PlatformUtils {
|
||||
|
||||
public static boolean isTest() {
|
||||
return isJUnit() || isRobolectric() || !isAndroid();
|
||||
}
|
||||
|
||||
public static boolean isJUnit() {
|
||||
try {
|
||||
Class.forName("org.junit.Test");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRobolectric() {
|
||||
try {
|
||||
Class.forName("org.robolectric.Robolectric");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAndroid() {
|
||||
try {
|
||||
Class.forName("android.os.Build");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ open class BaseTest {
|
||||
@JvmStatic
|
||||
@BeforeClass
|
||||
fun setup() {
|
||||
LibraryLoader.enableErrorHandling(true)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user