Skip to content

--requirements=android gives crash #1504

Closed
@RobertFlatt

Description

@RobertFlatt

Versions

  • Python: 3.6
  • OS: Ubuntu 18.04.1
  • Kivy: whatever p4a downloads
  • Cython: 0.29.1
  • p4a: master as of 12/6/2018

Description

Three command line option issues:

  1. "--requirement=android" causes p4a crash

If .p4a contains these two lines:


--bootstrap=sdl2
--requirements=python3,kivy,android

p4a fails because --bootstrap value is encoded as a str not utf-8

The problem is with encoding of bootstrap string in:
/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipes/android/__init__.py


bootstrap = bootstrap_name = self.ctx.bootstrap.name.decode('utf-8')

Assumes the --boostrap option is encoded as 'utf-8', I think all options are 'str'; except the requirements option which is re-coded to 'utf -8'.

A workaround is removing the decode(), this fixes the problem for me


bootstrap = bootstrap_name = self.ctx.bootstrap.name

  1. Presplash

--presplash depends on the 'android' package, though there is no easy way for a user to know this.

But 'android' is not loaded by default.

Enhancement request: Add 'android' to 'requirements' if it is not specified, and --presplash specified

  1. Ndk_api

toolchain.py line 268 :


            '--ndk-api', type=int, default=None,

is missing an argument, change to


            '--ndk-api', '--ndk_api', type=int, default=None,

Command:

p4a apk

.p4a file:

--dist_name=yy
--private .
--package=com.xxx.yy
--name Yy
--bootstrap=sdl2
--requirements=python3,kivy,android
--arch=armeabi-v7a
--permission INTERNET
--orientation sensor
--icon chart.png
--presplash chart.jpg
--sdk_dir /someplace/androidtools/sdk
--ndk_dir /someplace/androidtools/android-ndk-r17c
--ndk_version 17c
--android_api 28
--ndk-api 21
--version 0.3.14

Logs


Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 11, in <module>
    load_entry_point('python-for-android==0.6.0', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 1032, in main
    ToolchainCL()
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 554, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 152, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 192, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/build.py", line 635, in build_recipes
    recipe.prebuild_arch(arch)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipes/android/__init__.py", line 36, in prebuild_arch
    bootstrap = bootstrap_name = self.ctx.bootstrap.name.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions