Closed
Description
when building an app with python3, numpy and opencv I get a runtime error (Android 7.0, latest p4a):
python : File "/home/phil/dev/kivy/cvtest/.buildozer/android/platform/build/build/python-installs/cvtest400/android/__init__.py", line 8, in <module>
python : File "android/_android.pyx", line 178, in init android._android
python : TypeError: must be str, not bytes
this is due to a concatenation of two strings of which one is not guaranteed to be unicode. This can be repaired by applying the following patch:
diff --git a/pythonforandroid/recipes/android/src/android/_android.pyx b/pythonforandroid/recipes/android/src/android/_android.pyx
index d332eed..4d77ebc 100644
--- a/pythonforandroid/recipes/android/src/android/_android.pyx
+++ b/pythonforandroid/recipes/android/src/android/_android.pyx
@@ -174,8 +174,8 @@ from jnius import autoclass, PythonJavaClass, java_method, cast
api_version = autoclass('android.os.Build$VERSION').SDK_INT
version_codes = autoclass('android.os.Build$VERSION_CODES')
-
-python_act = autoclass(JAVA_NAMESPACE + u'.PythonActivity')
+java_namespace = JAVA_NAMESPACE.decode() if isinstance(JAVA_NAMESPACE, bytes) else JAVA_NAMESPACE
+python_act = autoclass(java_namespace + u'.PythonActivity')
Rect = autoclass(u'android.graphics.Rect')
mActivity = python_act.mActivity
if mActivity:
Metadata
Metadata
Assignees
Labels
No labels