Skip to content
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

"Python for android ended." When printing \x00 #2415

Closed
C1em opened this issue Feb 1, 2021 · 0 comments · Fixed by #2416
Closed

"Python for android ended." When printing \x00 #2415

C1em opened this issue Feb 1, 2021 · 0 comments · Fixed by #2416

Comments

@C1em
Copy link

C1em commented Feb 1, 2021

Versions

  • Python: 3.7.0
  • OS: macOS 10.15.7
  • Cython: 0.29.21
  • OpenJDK: adoptopenjdk8: 8,275:b01

Description

I am trying to have a Python service and Java native android work together.
the Java native code is in an Android Studio project and Python service is built into an aar with p4a.
I launch my Python service in MainActivity.java:OnCreate like this:

val context = applicationContext
ServicePython.prepare(context)
ServicePython.start(context, "")

And that works fine but for debugging purpose, in my PythonService, I tried to print the \0 byte like this:
print("\x00")

And then in the logcat I have:
2021-02-01 15:05:56.570 1154-1421/com.example.myapplication I/python: Python for android ended.

I expected to see an empty line in the logcat like:

2021-02-01 15:05:56.570 1154-1421/com.example.myapplication I/PythonService: 

I also tried with \x41 and that works as expected, a "A" get printed, it seems to be specific to \x00.

Command to build the Python service as an aar:

p4a aar \
	--private $BASEDIR/python_service \
	--package=com.exemple.python\
	--name python_lib \
	--version 0.1 \
	--requirements=python3 \
	--sdk-dir=~/Library/Android/sdk \
	--ndk-dir=~/Library/Android/sdk/ndk/19.2.5345600 \
	--bootstrap service_library \
	--permission INTERNET \
	--storage-dir $BUILD_DIR \
	--service PythonService:service.py:foreground \
	--arch arm64-v8a \
	--android_api 28 \
	--ndk-api 23 \
	--minsdk 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant