diff --git a/android-kiwix-lib-publisher/kiwixLibAndroid/build.gradle b/android-kiwix-lib-publisher/kiwixLibAndroid/build.gradle index f6dc9616e..4ff6a01d2 100644 --- a/android-kiwix-lib-publisher/kiwixLibAndroid/build.gradle +++ b/android-kiwix-lib-publisher/kiwixLibAndroid/build.gradle @@ -14,4 +14,8 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } -} \ No newline at end of file +} + +dependencies { + implementation 'com.getkeepsafe.relinker:relinker:1.3.1' +} diff --git a/src/android/kiwix.cpp b/src/android/kiwixicu.cpp similarity index 91% rename from src/android/kiwix.cpp rename to src/android/kiwixicu.cpp index 1dfef6903..4c6b23e04 100644 --- a/src/android/kiwix.cpp +++ b/src/android/kiwixicu.cpp @@ -19,7 +19,7 @@ */ #include -#include "org_kiwix_kiwixlib_JNIKiwix.h" +#include "org_kiwix_kiwixlib_JNIICU.h" #include #include @@ -30,7 +30,7 @@ pthread_mutex_t globalLock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; -JNIEXPORT void JNICALL Java_org_kiwix_kiwixlib_JNIKiwix_setDataDirectory( +JNIEXPORT void JNICALL Java_org_kiwix_kiwixlib_JNIICU_setDataDirectory( JNIEnv* env, jobject obj, jstring dirStr) { std::string cPath = jni2c(dirStr, env); diff --git a/src/android/meson.build b/src/android/meson.build index d02fc25e3..e871ad3fa 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -1,6 +1,6 @@ kiwix_jni = custom_target('jni', - input: ['org/kiwix/kiwixlib/JNIKiwix.java', + input: ['org/kiwix/kiwixlib/JNIICU.java', 'org/kiwix/kiwixlib/JNIKiwixReader.java', 'org/kiwix/kiwixlib/JNIKiwixSearcher.java', 'org/kiwix/kiwixlib/JNIKiwixInt.java', @@ -16,7 +16,7 @@ kiwix_jni = custom_target('jni', ) kiwix_sources += [ - 'android/kiwix.cpp', + 'android/kiwixicu.cpp', 'android/kiwixreader.cpp', 'android/kiwixsearcher.cpp', kiwix_jni] diff --git a/src/android/org/kiwix/kiwixlib/JNIICU.java b/src/android/org/kiwix/kiwixlib/JNIICU.java new file mode 100644 index 000000000..db8ba6efb --- /dev/null +++ b/src/android/org/kiwix/kiwixlib/JNIICU.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2013 Emmanuel Engelhart + * Copyright (C) 2017 Matthieu Gautier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.kiwixlib; + +public class JNIICU +{ + static public native void setDataDirectory(String icuDataDir); +} diff --git a/src/android/org/kiwix/kiwixlib/JNIKiwix.java b/src/android/org/kiwix/kiwixlib/JNIKiwix.java index 0d79db697..57e148b23 100644 --- a/src/android/org/kiwix/kiwixlib/JNIKiwix.java +++ b/src/android/org/kiwix/kiwixlib/JNIKiwix.java @@ -20,12 +20,17 @@ package org.kiwix.kiwixlib; -import org.kiwix.kiwixlib.JNIKiwixReader; -import org.kiwix.kiwixlib.JNIKiwixString; +import android.content.Context; +import com.getkeepsafe.relinker.ReLinker; +import org.kiwix.kiwixlib.JNIICU; public class JNIKiwix { - static { System.loadLibrary("kiwix"); } + public JNIKiwix(final Context context){ + ReLinker.loadLibrary(context, "kiwix"); + } - public native void setDataDirectory(String icuDataDir); + public void setDataDirectory(String icuDataDir) { + JNIICU.setDataDirectory(icuDataDir); + } }