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

Commit

Permalink
[android] - change library loader to soloader
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jun 11, 2019
1 parent d7fa18e commit 685a9e5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
6 changes: 3 additions & 3 deletions platform/android/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)

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

Mapbox GL uses portions of the ReLinker.
URL: [https://github.com/KeepSafe/ReLinker](https://github.com/KeepSafe/ReLinker)
License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
Mapbox GL uses portions of the SoLoader.
URL: [https://github.com/facebook/soloader](https://github.com/facebook/soloader)
License: [BSD License](https://github.com/facebook/soloader/blob/master/LICENSE)

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

Expand Down
2 changes: 1 addition & 1 deletion platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
implementation dependenciesList.supportAnnotations
implementation dependenciesList.supportFragmentV4
implementation dependenciesList.okhttp3
implementation dependenciesList.reLinker
implementation dependenciesList.soLoader
testImplementation dependenciesList.junit
testImplementation dependenciesList.mockito
testImplementation dependenciesList.mockk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.mapbox.mapboxsdk.module.loader;

import android.content.Context;
import com.getkeepsafe.relinker.ReLinker;
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>
Expand All @@ -23,36 +24,26 @@ public class LibraryLoaderProviderImpl implements LibraryLoaderProvider {
*/
@Override
public LibraryLoader getDefaultLibraryLoader() {
return new ReLinkerLibraryLoader();
return new SoLibraryLoader();
}

/**
* Concrete implementation of a LibraryLoader using ReLinker.
*/
private static class ReLinkerLibraryLoader extends LibraryLoader {
private static class SoLibraryLoader extends LibraryLoader {

private static final String TAG = "SoLibraryLoader";

@Override
public void load(String name) {
try {
Context context = Mapbox.getApplicationContext();
ReLinker.log(new LibraryLogger()).loadLibrary(context, name);
// nativeExopackage = false, https://buck.build/article/exopackage.html
init(Mapbox.getApplicationContext(), false);
loadLibrary(name);
} catch (MapboxConfigurationException exception) {
Logger.e(LibraryLogger.TAG, "Couldn't load so file with relinker, application context missing, "
Logger.e(TAG, "Couldn't load so file with relinker, application context missing, "
+ "call Mapbox.getInstance(Context context, String accessToken) first");
}
}

/**
* Relinker library loader logger.
*/
private static class LibraryLogger implements ReLinker.Logger {

private static final String TAG = "Mbgl-LibraryLoader";

@Override
public void log(String message) {
Logger.d(TAG, message);
}
}
}
}
4 changes: 2 additions & 2 deletions platform/android/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ext {
androidPublish : '3.6.2',
lint : '26.1.4',
gms : '16.0.0',
reLinker : '1.3.1',
soLoader : '0.6.0',
jacoco : '0.8.3'
]

Expand Down Expand Up @@ -68,7 +68,7 @@ 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}",
reLinker : "com.getkeepsafe.relinker:relinker:${versions.reLinker}",
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 685a9e5

Please sign in to comment.