Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Rollback to System.loadLibrary to load native library. (#368)
Browse files Browse the repository at this point in the history
* Rollback to System.loadLibrary if SoLoader failed to load library.

* Remove soloader.
  • Loading branch information
Kevin Li authored May 7, 2020
1 parent 9d5b1f6 commit 01f1b1e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 51 deletions.
18 changes: 0 additions & 18 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,6 @@ License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)

===========================================================================

Mapbox GL uses portions of SoLoader.
URL: [https://github.com/facebook/soloader](https://github.com/facebook/soloader)
License: [Apache-2](https://github.com/facebook/soloader/blob/master/LICENSE)

===========================================================================

Mapbox GL uses portions of SoLoader.
URL: [https://github.com/facebook/soloader](https://github.com/facebook/soloader)
License: [Apache-2](https://github.com/facebook/soloader/blob/master/LICENSE)

===========================================================================

Mapbox GL uses portions of SoLoader.
URL: [https://github.com/facebook/soloader](https://github.com/facebook/soloader)
License: [Apache-2](https://github.com/facebook/soloader/blob/master/LICENSE)

===========================================================================

Mapbox GL uses portions of VersionedParcelable and friends.
URL: [http://developer.android.com/tools/extras/support-library.html](http://developer.android.com/tools/extras/support-library.html)
License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
Expand Down
1 change: 0 additions & 1 deletion MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies {
implementation dependenciesList.supportAnnotations
implementation dependenciesList.supportFragmentV4
implementation dependenciesList.okhttp3
implementation dependenciesList.soLoader
testImplementation dependenciesList.junit
testImplementation dependenciesList.mockito
testImplementation dependenciesList.mockk
Expand Down
8 changes: 1 addition & 7 deletions MapboxGLAndroidSDK/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,4 @@
# while we don't include this dependency directly
# a large amount of users combine it with our SDK
# we aren't able to provide a proguard config in that project (jar vs aar)
-dontwarn com.sun.xml.internal.ws.spi.db.*

# config for SoLoader https://github.com/mapbox/mapbox-gl-native-android/issues/60,
# https://github.com/facebook/SoLoader/blob/master/java/com/facebook/soloader/soloader.pro
-keep class com.facebook.soloader.SysUtil$LollipopSysdeps {
public <methods>;
}
-dontwarn com.sun.xml.internal.ws.spi.db.*
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Loads the mapbox-gl shared library
* <p>
* By default uses SoLoader from https://github.com/facebook/SoLoader
* By default uses System.loadLibrary
* use {@link #setLibraryLoader(LibraryLoader)} to provide an alternative library loading hook.
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

import com.mapbox.mapboxsdk.LibraryLoader;
import com.mapbox.mapboxsdk.LibraryLoaderProvider;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
import com.mapbox.mapboxsdk.log.Logger;

import static com.facebook.soloader.SoLoader.init;
import static com.facebook.soloader.SoLoader.loadLibrary;

/**
* Concrete implementation of a native library loader.
* <p>
* Uses SoLoader from https://github.com/facebook/SoLoader.
* </p>
*/
public class LibraryLoaderProviderImpl implements LibraryLoaderProvider {
Expand All @@ -24,27 +17,16 @@ public class LibraryLoaderProviderImpl implements LibraryLoaderProvider {
*/
@Override
public LibraryLoader getDefaultLibraryLoader() {
return new SoLibraryLoader();
return new SystemLibraryLoader();
}

/**
* Concrete implementation of a LibraryLoader using SoLoader.
* Concrete implementation of a LibraryLoader using System.loadLibrary.
*/
private static class SoLibraryLoader extends LibraryLoader {

private static final String TAG = "SoLibraryLoader";

private static class SystemLibraryLoader extends LibraryLoader {
@Override
public void load(String name) {
try {
// nativeExopackage = false, https://buck.build/article/exopackage.html
init(Mapbox.getApplicationContext(), false);
loadLibrary(name);
} 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());
}
System.loadLibrary(name);
}
}
}
2 changes: 0 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ext {
androidPublish : '3.6.2',
lint : '26.4.2',
gms : '16.0.0',
soLoader : '0.8.0',
jacoco : '0.8.4',
appcenter : '1.4',
ktlint : '0.34.0',
Expand Down Expand Up @@ -74,7 +73,6 @@ ext {
okhttp3 : "com.squareup.okhttp3:okhttp:${versions.okhttp}",
leakCanaryDebug : "com.squareup.leakcanary:leakcanary-android:${versions.leakCanary}",
leakCanaryRelease : "com.squareup.leakcanary:leakcanary-android-no-op:${versions.leakCanary}",
soLoader : "com.facebook.soloader:soloader:${versions.soLoader}",

kotlinLib : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}",
kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
Expand Down

0 comments on commit 01f1b1e

Please sign in to comment.