#239 ReLinker should be used to load library

This commit is contained in:
Sean Mac Gillicuddy 2019-07-25 15:26:25 +01:00 committed by Matthieu Gautier
parent 93c404a952
commit 5adf7891cc
5 changed files with 44 additions and 9 deletions

View File

@ -15,3 +15,7 @@ android {
}
}
}
dependencies {
implementation 'com.getkeepsafe.relinker:relinker:1.3.1'
}

View File

@ -19,7 +19,7 @@
*/
#include <jni.h>
#include "org_kiwix_kiwixlib_JNIKiwix.h"
#include "org_kiwix_kiwixlib_JNIICU.h"
#include <iostream>
#include <string>
@ -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);

View File

@ -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]

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2013 Emmanuel Engelhart <kelson@kiwix.org>
* Copyright (C) 2017 Matthieu Gautier <mgautier@kymeria.fr>
*
* 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);
}

View File

@ -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);
}
}