I'm trying to build an apk for a simple python3/kivy app using buildozer in the virtual machine I got straight from kivy.org, this is day2. I had many errors, instaled pip, updated buildozer, pip installed morse, pnglab, sh, appdirs, setuptools for py3, now I'm at this error when I write $ buildozer android debug, my virtual machine uses python 2.7 and 3.4, anyone know what is this about? I would very much apreciate an answer as I am planning to make droid development my job some day, thank you. This is the error: AttributeError: 'str' object has no attribute 'decode'
And the Traceback:
Traceback (most recent call last):
File "/usr/local/bin/buildozer", line 9, in <module> load_entry_point('buildozer==0.32dev', 'console_scripts', 'buildozer')()
File "/usr/local/lib/python3.4/dist-packages/buildozer-0.32dev-py3.4.eg /buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/usr/local/lib/python3.4/dist-packages/buildozer-0.32dev-py3.4.egg/buildozer/__init__.py", line 992, in run_command
self.target.run_commands(args)
File "/usr/local/lib/python3.4/dist-packages/buildozer-0.32dev-py3.4.egg/buildozer/target.py", line 85, in run_commands
func(args)
File "/usr/local/lib/python3.4/dist-packages/buildozer-0.32dev-py3.4.egg/buildozer/target.py", line 97, in cmd_debug
self.buildozer.build()
File "/usr/local/lib/python3.4/dist-packages/buildozer-0.32dev-py3.4.egg/buildozer/__init__.py", line 198, in build
self.target.build_package()
File "/usr/local/lib/python3.4/dist-packages/buildozer-0.32dev-py3.4.egg/buildozer/targets/android.py", line 747, in build_package
apktitle = ''.join([x for x in config.get('app', 'title').decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'
This looks like a bug in buildozer. You can possibly work around it by using python2. Feel free to create an issue about it on buildozer's github page.
Related
I'm currently trying to compile a simple Kivy app for use on Android. It runs in both my windows and linux environments without errors or warnings. When I go to package it using buildozer I get an error almost immediately. I did search for this error and although the title is very similar to other questions, the error is not.
Output from buildozer:
(mykivyinstall) oli#Bud: buildozer android debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
Traceback (most recent call last):
File "/home/oli/mykivyinstall/bin/buildozer", line 11, in <module>
sys.exit(main())
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/__init__.py", line 1059, in run_command
self.target.run_commands(args)
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/target.py", line 92, in run_commands
func(args)
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/target.py", line 102, in cmd_debug
self.buildozer.prepare_for_build()
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/__init__.py", line 176, in prepare_for_build
self.target.install_platform()
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/targets/android.py", line 467, in install_platform
self._install_p4a()
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/targets/android.py", line 524, in _install_p4a
deps = re.findall("^install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
IndexError: list index out of range
My environment:
buildozer version=0.35
cython version=0.25.2
python version=3.6.6
OS is Ubuntu=18.04
Am I mixing and matching the wrong versions of things?
This seems a like a bug in the latest version of buildozer. The solution is to edit the file "../python3.6/site-packages/buildozer/targets/android.py" and replace the line
deps = re.findall("^install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
with
deps = re.findall("install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
Then run buildozer -v android debug
I am stuck with a similar problem mentioned in:
python kivy with plyer app crashes on android (camera)
which is related to crash of android application when it uses the camera using python plyer library.
I understood that I can use the old_toolchain of python-for-android since the new master version still has an issue that has not been solved yet.
Running buildozer automatically clones the latest python-for-android master, so the question is how to make it clones the old version and use it instead?
I tried to run buildozer as follows:
buildozer android_old debug
but I got the following error:
Traceback (most recent call last):
File "/usr/local/bin/buildozer", line 9, in <module>
load_entry_point('buildozer==0.33', 'console_scripts', 'buildozer')()
File "/usr/local/lib/python2.7/dist-packages/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 1058, in run_command
self.target.run_commands(args)
File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 91, in run_commands
func(args)
File "/usr/local/lib/python2.7/dist-packages/buildozer/target.py", line 103, in cmd_debug
self.buildozer.build()
File "/usr/local/lib/python2.7/dist-packages/buildozer/__init__.py", line 212, in build
self.target.build_package()
File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 663, in build_package
self._update_libraries_references(dist_dir)
File "/usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py", line 857, in _update_libraries_references
if not content[-1].endswith(u'\n'):
IndexError: list index out of range
I have created a pygame application. Now I want to create an APK and for that I need to install pygame_sdl2. However, when I try to install by running python setup.py install I get this error
Traceback (most recent call last):
File "C:\pygame_sdl2-master\setup.py", line 36, in <module>
parse_cflags([ "sh", "-c", "sdl2-config --cflags" ])
File "C:\pygame_sdl2-master\setuplib.py", line 93, in parse_cflags
output = subprocess.check_output(command, universal_newlines=True)
File "C:\Python27\lib\subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Any help in this context would be appreciated.
Download the version you need here https://bitbucket.org/marcusva/py-sdl2/downloads
Exctract, open the cmd and navigate to the folder.
Run python setup.py install
Working for me this way.I downloaded PySDL2-0.9.3.zip file
I am trying to run Systrace but I get an error when I run the command.
user1#PC1:~/Android/Sdk/platform-tools/systrace$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
user1#PC1:~/Android/Sdk/platform-tools/systrace$ ls
AUTHORS prefix.html systrace.py
LICENSE suffix.html systrace_trace_viewer.html
NOTICE systrace-legacy.py UPSTREAM_REVISION
user1#PC1:~/Android/Sdk/platform-tools/systrace$ python systrace.py --time=10 -o mynewtrace.html
Traceback (most recent call last):
File "systrace.py", line 320, in <module>
main()
File "systrace.py", line 158, in main
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I am currently running Ubuntu with Android SDK 5.1.1 installed along with Android Studio. Below is are my PATH export in .bashrc:
export PATH="~/Applications/android-studio/bin/:$PATH"
export PATH="~/Android/Sdk/platform-tools/:$PATH"
export PATH="~/Android/Sdk/tools/:$PATH"
Even though the answer is accepted, for those who face this problem in the future;
Run systrace from /platform-tools directory(adb is in /platform-tools directory) not from /platform-tools/systrace directory. E.g.
.../platform-tools$ python systrace/systrace.py
I fixed the issues by changing my PATH export to be specified by absolute path instead of relative path. This means, I can't define my home directory using ~/..., I have to use /home/username/....
export PATH="/home/user1/Applications/android-studio/bin/:$PATH"
export PATH="/home/user1/Android/Sdk/platform-tools/:$PATH"
export PATH="/home/user1/Android/Sdk/tools/:$PATH"
However, it is not clear to me why systrace.py won't properly run when PATH is defined using ~/... instead of /home/username/.... ADB works perfectly fine when the PATH is defined using ~/....
New to android and wanted to do a little debugging with the systrace tool however I am unable to run the tool on the emulator (tried running the python script with python 2.0.1, 2.7.x, 3.x) as well as using ADT.
However they all produce different errors:
Developers | Systrace claims that it requires 2.x so using Python 2.x and executing python command systrace.py --help, I get:
C:\Development\Android\sdk\platform-tools\systrace>python systrace.py --help
Traceback (most recent call last):
File "systrace.py", line 286, in <module>
main()
File "systrace.py", line 60, in main
device_sdk_version = get_device_sdk_version()
File "systrace.py", line 44, in get_device_sdk_version
stderr=subprocess.PIPE)
File "C:\Reuben\Softwares\Python 2.7.6\Lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Reuben\Softwares\Python 2.7.6\Lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
C:\Development\Android\sdk\platform-tools\systrace>python systrace.py --help
File "systrace.py", line 135
css = '\n'.join(linked_css_tag % (os.path.join(src_dir, f)) for f in css_files)
^
SyntaxError: invalid syntax
But with Admin permission:
C:\Development\Android\sdk\platform-tools\systrace>systrace.py --help
File "C:\Development\Android\sdk\platform-tools\systrace\systrace.py", line 135
css = '\n'.join(linked_css_tag % (os.path.join(src_dir, f)) for f in css_files)
^
SyntaxError: invalid syntax
With ADT settings
Error dialog
Other Relevant Information:
Enabled: Android Debugging, Profile GPU rendering
Enable OpenGL traces: Systrace (Graphics)
Enable traces: Graphics,Input
Tried Other solution but got "mount: Device or resource busy"