Skip to content

Commit f33b4bd

Browse files
committed
try to fix plyer
1 parent 1e3334b commit f33b4bd

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

bootstrap/minimal/jni/main.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
#endif
1414

1515
struct android_app *g_state = NULL;
16+
static JNIEnv *g_env = NULL;
1617

1718

19+
JNIEnv *minimal_get_jnienv() {
20+
return g_env;
21+
}
22+
1823
static PyObject *androidembed_poll(PyObject *self, PyObject *args) {
1924
int indent;
2025
int events;
@@ -96,6 +101,8 @@ void android_main(struct android_app* state) {
96101
//env_argument = getenv("ANDROID_ARGUMENT");
97102
//setenv("ANDROID_APP_PATH", env_argument, 1);
98103
//setenv("PYTHONVERBOSE", "2", 1);
104+
setenv("PYJNIUS_JNIENV_SYMBOL", "minimal_get_jnienv", 1);
105+
setenv("ANDROID_ARGUMENT", "", 1); // needed for plyer
99106
Py_SetProgramName("python-android");
100107
Py_Initialize();
101108
//PySys_SetArgv(argc, argv);
@@ -108,23 +115,22 @@ void android_main(struct android_app* state) {
108115

109116
// get the APK filename, and set it to ANDROID_APK_FN
110117
ANativeActivity* activity = state->activity;
111-
JNIEnv* env = NULL;
112-
(*activity->vm)->AttachCurrentThread(activity->vm, &env, 0);
113-
jclass clazz = (*env)->GetObjectClass(env, activity->clazz);
114-
jmethodID methodID = (*env)->GetMethodID(env, clazz, "getPackageCodePath", "()Ljava/lang/String;");
115-
jobject result = (*env)->CallObjectMethod(env, activity->clazz, methodID);
118+
(*activity->vm)->AttachCurrentThread(activity->vm, &g_env, 0);
119+
jclass clazz = (*g_env)->GetObjectClass(g_env, activity->clazz);
120+
jmethodID methodID = (*g_env)->GetMethodID(g_env, clazz, "getPackageCodePath", "()Ljava/lang/String;");
121+
jobject result = (*g_env)->CallObjectMethod(g_env, activity->clazz, methodID);
116122
const char* str;
117123
jboolean isCopy;
118-
str = (*env)->GetStringUTFChars(env, (jstring)result, &isCopy);
124+
str = (*g_env)->GetStringUTFChars(g_env, (jstring)result, &isCopy);
119125
LOGI("Looked up package code path: %s", str);
120126
setenv("ANDROID_APK_FN", str, 1);
121127

122-
methodID = (*env)->GetMethodID(env, clazz, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
123-
jobject appInfo = (*env)->CallObjectMethod(env, activity->clazz, methodID);
124-
jfieldID fieldID = (*env)->GetFieldID(env,
125-
(*env)->GetObjectClass(env, appInfo), "nativeLibraryDir", "Ljava/lang/String;");
126-
result = (*env)->GetObjectField(env, appInfo, fieldID);
127-
str = (*env)->GetStringUTFChars(env, (jstring)result, &isCopy);
128+
methodID = (*g_env)->GetMethodID(g_env, clazz, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
129+
jobject appInfo = (*g_env)->CallObjectMethod(g_env, activity->clazz, methodID);
130+
jfieldID fieldID = (*g_env)->GetFieldID(g_env,
131+
(*g_env)->GetObjectClass(g_env, appInfo), "nativeLibraryDir", "Ljava/lang/String;");
132+
result = (*g_env)->GetObjectField(g_env, appInfo, fieldID);
133+
str = (*g_env)->GetStringUTFChars(g_env, (jstring)result, &isCopy);
128134
LOGI("Looked up library code path: %s", str);
129135
setenv("ANDROID_LIB_PATH", str, 1);
130136

distribute.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ BOOTSTRAP_COMMON_PATH="$BOOTSTRAP_PATH/common"
6363
export LIBLINK_PATH="$BUILD_PATH/objects"
6464
export LIBLINK="$ROOT_PATH/tools/liblink"
6565
export BIGLINK="$ROOT_PATH/tools/biglink"
66+
export LIBLINK=ld
67+
export BIGLING=true
6668
export PIP=$PIP_NAME
6769
export VIRTUALENV=$VIRTUALENV_NAME
6870

recipes/plyer/recipe.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
VERSION_plyer=${VERSION_plyer:-master}
44
URL_plyer=https://github.com/kivy/plyer/zipball/$VERSION_plyer/plyer-$VERSION_plyer.zip
5-
DEPS_plyer=(pyjnius android)
5+
DEPS_plyer=(pyjnius)
66
MD5_plyer=
77
BUILD_plyer=$BUILD_PATH/plyer/$(get_directory $URL_plyer)
88
RECIPE_plyer=$RECIPES_PATH/plyer

0 commit comments

Comments
 (0)