8000 Fix loadLibraries() failing on 64bit arch (#1701) · lstwzd/python-for-android@5d0f92e · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d0f92e

Browse files
j-develinclement
authored andcommitted
Fix loadLibraries() failing on 64bit arch (kivy#1701)
1 parent 6ca419e commit 5d0f92e

File tree

6 files changed

+16
-22
lines changed

6 files changed

+16
-22
lines changed

pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public void onTaskRemoved(Intent rootIntent) {
144144
public void run(){
145145
String app_root = getFilesDir().getAbsolutePath() + "/app";
146146
File app_root_file = new File(app_root);
147-
PythonUtil.loadLibraries(app_root_file);
147+
PythonUtil.loadLibraries(app_root_file,
148+
new File(getApplicationInfo().nativeLibraryDir));
148149
this.mService = this;
149150
nativeStart(
150151
androidPrivate, androidArgument,

pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ protected static void addLibraryIfExists(ArrayList<String> libsList, String patt
3030
}
3131
}
3232

33-
protected static ArrayList<String> getLibraries(File filesDir) {
34-
35-
String libsDirPath = filesDir.getParentFile().getParentFile().getAbsolutePath() + "/lib/";
36-
File libsDir = new File(libsDirPath);
37-
33+
protected static ArrayList<String> getLibraries(File libsDir) {
3834
ArrayList<String> libsList = new ArrayList<String>();
3935
addLibraryIfExists(libsList, "crystax", libsDir);
4036
addLibraryIfExists(libsList, "sqlite3", libsDir);
@@ -49,14 +45,13 @@ protected static ArrayList<String> getLibraries(File filesDir) {
4945
return libsList;
5046
}
5147

52-
public static void loadLibraries(File filesDir) {
53-
48+
public static void loadLibraries(File filesDir, File libsDir) {
5449
String filesDirPath = filesDir.getAbsolutePath();
5550
boolean foundPython = false;
5651

57-
for (String lib : getLibraries(filesDir)) {
52+
for (String lib : getLibraries(libsDir)) {
5853
Log.v(TAG, "Loading library: " + lib);
59-
try {
54+
try {
6055
System.loadLibrary(lib);
6156
if (lib.startsWith("python")) {
6257
foundPython = true;

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ protected void onCreate(Bundle savedInstanceState) {
8383
public void loadLibraries() {
8484
String app_root = new String(getAppRoot());
8585
File app_root_file = new File(app_root);
86-
PythonUtil.loadLibraries(app_root_file);
86+
PythonUtil.loadLibraries(app_root_file,
87+
new File(getApplicationInfo().nativeLibraryDir));
8788
}
8889

8990
public void recursiveDelete(File f) {

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonUtil.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ protected static void addLibraryIfExists(ArrayList<String> libsList, String patt
2929
}
3030
}
3131

32-
protected static ArrayList<String> getLibraries(File filesDir) {
33-
34-
String libsDirPath = filesDir.getParentFile().getParentFile().getAbsolutePath() + "/lib/";
35-
File libsDir = new File(libsDirPath);
36-
32+
protected static ArrayList<String> getLibraries(File libsDir) {
3733
ArrayList<String> libsList = new ArrayList<String>();
3834
addLibraryIfExists(libsList, "crystax", libsDir);
3935
addLibraryIfExists(libsList, "sqlite3", libsDir);
@@ -52,14 +48,13 @@ protected static ArrayList<String> getLibraries(File filesDir) {
5248
return libsList;
5349
}
5450

55-
public static void loadLibraries(File filesDir) {
56-
51+
public static void loadLibraries(File filesDir, File libsDir) {
5752
String filesDirPath = filesDir.getAbsolutePath();
5853
boolean foundPython = false;
5954

60-
for (String lib : getLibraries(filesDir)) {
55+
for (String lib : getLibraries(libsDir)) {
6156
Log.v(TAG, "Loading library: " + lib);
62-
try {
57+
try {
6358
System.loadLibrary(lib);
6459
if (lib.startsWith("python")) {
6560
foundPython = true;

pythonforandroid/bootstraps/service_only/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ public void onDestroy() {
201201
public void loadLibraries() {
202202
String app_root = new String(getAppRoot());
203203
File app_root_file = new File(app_root);
204-
PythonUtil.loadLibraries(app_root_file);
204+
PythonUtil.loadLibraries(app_root_file,
205+
new File(getApplicationInfo().nativeLibraryDir));
205206
}
206207

207208
public void recursiveDelete(File f) {

pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ public void onDestroy() {
232232
public void loadLibraries() {
233233
String app_root = new String(getAppRoot());
234234
File app_root_file = new File(app_root);
235-
PythonUtil.loadLibraries(app_root_file);
235+
PythonUtil.loadLibraries(app_root_file,
236+
new File(getApplicationInfo().nativeLibraryDir));
236237
}
237238

238239
public void recursiveDelete(File f) {

0 commit comments

Comments
 (0)
0