Skip to content

Fix loadLibraries() failing for 64bit arch #1701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public void onTaskRemoved(Intent rootIntent) {
public void run(){
String app_root = getFilesDir().getAbsolutePath() + "/app";
File app_root_file = new File(app_root);
PythonUtil.loadLibraries(app_root_file);
PythonUtil.loadLibraries(app_root_file,
new File(getApplicationInfo().nativeLibraryDir));
this.mService = this;
nativeStart(
androidPrivate, androidArgument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ protected static void addLibraryIfExists(ArrayList<String> libsList, String patt
}
}

protected static ArrayList<String> getLibraries(File filesDir) {

String libsDirPath = filesDir.getParentFile().getParentFile().getAbsolutePath() + "/lib/";
File libsDir = new File(libsDirPath);

protected static ArrayList<String> getLibraries(File libsDir) {
ArrayList<String> libsList = new ArrayList<String>();
addLibraryIfExists(libsList, "crystax", libsDir);
addLibraryIfExists(libsList, "sqlite3", libsDir);
Expand All @@ -49,14 +45,13 @@ protected static ArrayList<String> getLibraries(File filesDir) {
return libsList;
}

public static void loadLibraries(File filesDir) {

public static void loadLibraries(File filesDir, File libsDir) {
String filesDirPath = filesDir.getAbsolutePath();
boolean foundPython = false;

for (String lib : getLibraries(filesDir)) {
for (String lib : getLibraries(libsDir)) {
Log.v(TAG, "Loading library: " + lib);
try {
try {
System.loadLibrary(lib);
if (lib.startsWith("python")) {
foundPython = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ protected void onCreate(Bundle savedInstanceState) {
public void loadLibraries() {
String app_root = new String(getAppRoot());
File app_root_file = new File(app_root);
PythonUtil.loadLibraries(app_root_file);
PythonUtil.loadLibraries(app_root_file,
new File(getApplicationInfo().nativeLibraryDir));
}

public void recursiveDelete(File f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ protected static void addLibraryIfExists(ArrayList<String> libsList, String patt
}
}

protected static ArrayList<String> getLibraries(File filesDir) {

String libsDirPath = filesDir.getParentFile().getParentFile().getAbsolutePath() + "/lib/";
File libsDir = new File(libsDirPath);

protected static ArrayList<String> getLibraries(File libsDir) {
ArrayList<String> libsList = new ArrayList<String>();
addLibraryIfExists(libsList, "crystax", libsDir);
addLibraryIfExists(libsList, "sqlite3", libsDir);
Expand All @@ -52,14 +48,13 @@ protected static ArrayList<String> getLibraries(File filesDir) {
return libsList;
}

public static void loadLibraries(File filesDir) {

public static void loadLibraries(File filesDir, File libsDir) {
String filesDirPath = filesDir.getAbsolutePath();
boolean foundPython = false;

for (String lib : getLibraries(filesDir)) {
for (String lib : getLibraries(libsDir)) {
Log.v(TAG, "Loading library: " + lib);
try {
try {
System.loadLibrary(lib);
if (lib.startsWith("python")) {
foundPython = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public void onDestroy() {
public void loadLibraries() {
String app_root = new String(getAppRoot());
File app_root_file = new File(app_root);
PythonUtil.loadLibraries(app_root_file);
PythonUtil.loadLibraries(app_root_file,
new File(getApplicationInfo().nativeLibraryDir));
}

public void recursiveDelete(File f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public void onDestroy() {
public void loadLibraries() {
String app_root = new String(getAppRoot());
File app_root_file = new File(app_root);
PythonUtil.loadLibraries(app_root_file);
PythonUtil.loadLibraries(app_root_file,
new File(getApplicationInfo().nativeLibraryDir));
}

public void recursiveDelete(File f) {
Expand Down