You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix resolveAndroidApiVersion when running under Robolectric (ReactiveX#4912)
PlatformDependent.resolveAndroidApiVersion() tries to determine the
Android SDK version by reading the android.os.Build$VERSION#SDK_INT
field. When running under Robolectric, the class will be found (since
Robolectric bundles an original android.jar). However, the method is
using the system class loader for loading it (instead of the Robolectric
instrumenting class loader), which will not instrument the class to run
in the JVM. As a result, static initialization of the class fails with
an UnsatisfiedLinkError when calling SystemProperties.get(), which calls
native method native_get.
I fixed by using the default class loader instead. This would only make
a difference in the extremely rare case that the Android application
installs a class loader that's not capable of finding Android classes.
I tested that this behaves as expected on a device, fixes the issue
with Robolectric, and detects it's not Android otherwise (as proven
by the unit test).
0 commit comments