Skip to content

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

Closed
@C1em

Description

@C1em

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions