kivyMD APK crashes on start up (android) - python-3.x

I help me figure out what the problem may be.
Hi, I am having issues running my Kivy MD app on an android device.
After compiling my app into an apk I use a USB stick to transfer the
file onto an android phone. The app is successfully installed and
loads up the kivy splash screen but then the app closes. Please note
that I am not able to obtain a logcast as my mobile cannot connect
using 'run'(i have tried many methods but this isn't the issue)
resources:
kivy
kivymd
buildozer
python
-Ubuntu 20.04
I simplified things by writing a simple code to run in order to see if the issue was with my initial complex code: below is the code i ran:
1.main.py(including my kv)
from kivymd.app import MDApp
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivymd.uix.list import MDList
kv = """
ScreenManager:
StartUpScreen:
ContactScreen:
OptionsScreen:
<StartUpScreen>:
name: 'startup'
MDLabel:
text: 'ViV'
halign: 'center'
font_style: "H2"
theme_text_color: 'Primary'
MDFillRoundFlatButton:
text: 'NEXT'
pos_hint: {'center_x':0.5,'center_y':0.1}
on_press: root.manager.current = 'options'
elevation: 10
<ContactScreen>:
name: 'contact us'
BoxLayout:
orientation: 'vertical'
MDLabel:
text:'CONTACT INFORMATION'
text_size: self.size
valign: 'top'
halign: 'center'
font_style: "H5"
theme_text_color: 'Primary'
GridLayout:
cols: 1
row_default_height: 150
row_force_default: True
size_hint_y: None
height: self.minimum_height
padding: dp(10), dp(10)
spacing: dp(15)
#images here
SmartTileWithLabel:
source: "banner.jpg"
nocache: True
mipmap: True
elevation: 10
MDList:
OneLineAvatarListItem:
text: 'contact.viv.rsa#gmail.com'
IconLeftWidget:
icon:"email"
MDList:
OneLineAvatarListItem:
text: 'Call us on 081 424 9121\\n\ 083 730 3544'
IconLeftWidget:
icon:"phone"
MDList:
OneLineAvatarListItem:
text:'Check us out : #viv_rsa'
IconLeftWidget:
icon:"instagram"
MDList:
OneLineAvatarListItem:
text:'Find us on Facebook: VIV App'
IconLeftWidget:
icon:"facebook"
Widget:
MDFillRoundFlatButton:
text: 'BACK'
pos_hint: {'center_x':0.5,'center_y':0.05}
on_press: root.manager.current = 'options'
elevation: 10
<OptionsScreen>:
name: "options"
BoxLayout:
canvas:
Rectangle:
source: "COVERGIRL.jpg"
pos: self.pos
size: self.size
BoxLayout:
MDFillRoundFlatButton:
text: "PRODUCTS & SERVICES"
pos_hint: {'center_x':0.5,'center_y':0.55}
#on_release:root.manager.current= "city"
elevation: 10
MDFillRoundFlatButton:
text: "CONTACT US"
pos_hint: {'center_x':0.5,'center_y':0.45}
on_release: root.manager.current= "contact us"
elevation: 10
MDLabel:
text: 'not designed for children'
pos_hint: {'center_x':0.8,'center_y':0.08}
font_style: "Overline"
color: 255,255,255,1
"""
class StartUpScreen(Screen):
pass
class ContactScreen(Screen):
pass
class OptionsScreen(Screen):
pass
sm = ScreenManager()
sm.add_widget(StartUpScreen(name='startup'))
sm.add_widget(ContactScreen(name='contact us'))
sm.add_widget(OptionsScreen(name='options'))
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Red"
self.theme_cls.primary_hue = "A700"
self.theme_cls.theme_style = 'Dark'
screen = Builder.load_string(kv)
return screen
MainApp().run()
2.buildozer.spec file
> [app]
>
> # (str) Title of your application title = VIV
>
> # (str) Package name package.name = MainApp
>
> # (str) Package domain (needed for android/ios packaging) package.domain = org.viv
>
> # (str) Source code where the main.py live source.dir = .
>
> # (list) Source files to include (let empty to include all the files) source.include_exts = py,png,jpg,kv,atlas,xml,iml
>
> # (list) List of inclusions using pattern matching
> #source.include_patterns = assets/*,images/*.png
>
> # (list) Source files to exclude (let empty to not exclude anything)
> #source.exclude_exts = spec
>
> # (list) List of directory to exclude (let empty to not exclude anything)
> #source.exclude_dirs = tests, bin
>
> # (list) List of exclusions using pattern matching
> #source.exclude_patterns = license,images/*/*.jpg
>
> # (str) Application versioning (method 1) version = 0.2
>
> # (str) Application versioning (method 2)
> # version.regex = __version__ = ['"](.*)['"]
> # version.filename = %(source.dir)s/main.py
>
> # (list) Application requirements
> # comma separated e.g. requirements = sqlite3,kivy requirements = python3,kivy,https://github.com/kivymd/KivyMD/archive/master.zip,pygments,sdl2_ttf==2.0.15
>
> # (str) Custom source folders for requirements
> # Sets custom source for any requirements with recipes requirements.source.kivymd =kivymd
>
> # (list) Garden requirements
> #garden_requirements =
>
> # (str) Presplash of the application
> #presplash.filename = %(source.dir)s/data/presplash.png
>
> # (str) Icon of the application
> #icon.filename = %(source.dir)s/data/icon.png
>
> # (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) orientation = portrait
>
> # (list) List of service to declare
> #services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
>
> #
> # OSX Specific
> #
>
> #
> # author = © Copyright Info
>
> # change the major version of python used by the app
> #osx.python_version = 3
>
> # Kivy version to use
> #osx.kivy_version = 1.9.1
>
> #
> # Android specific
> #
>
> # (bool) Indicate if the application should be fullscreen or not fullscreen = 1
>
> # (string) Presplash background color (for new android toolchain)
> # Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
> # red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,
> # darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,
> # olive, purple, silver, teal. android.presplash_color = #FFFFFF
>
> # (list) Permissions android.permissions = INTERNET
>
> # (int) Target Android API, should be as high as possible. android.api = 29
>
> # (int) Minimum API your APK will support.
> #android.minapi = 21
>
> # (int) Android SDK version to use
> #android.sdk = 20
>
> # (str) Android NDK version to use
> #android.ndk = 19b
>
> # (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
> #android.ndk_api = 21
>
> # (bool) Use --private data storage (True) or --dir public storage (False)
> #android.private_storage = True
>
> # (str) Android NDK directory (if empty, it will be automatically downloaded.)
> #android.ndk_path =
>
> # (str) Android SDK directory (if empty, it will be automatically downloaded.)
> #android.sdk_path =
>
> # (str) ANT directory (if empty, it will be automatically downloaded.)
> #android.ant_path =
>
> # (bool) If True, then skip trying to update the Android sdk
> # This can be useful to avoid excess Internet downloads or save time
> # when an update is due and you just want to test/build your package
> # android.skip_update = False
>
> # (bool) If True, then automatically accept SDK license
> # agreements. This is intended for automation only. If set to False,
> # the default, you will be shown the license when first running
> # buildozer.
> # android.accept_sdk_license = False
>
> # (str) Android entry point, default is ok for Kivy-based app
> #android.entrypoint = org.renpy.android.PythonActivity
>
> # (str) Android app theme, default is ok for Kivy-based app
> # android.apptheme = "#android:style/Theme.NoTitleBar"
>
> # (list) Pattern to whitelist for the whole project
> #android.whitelist =
>
> # (str) Path to a custom whitelist file
> #android.whitelist_src =
>
> # (str) Path to a custom blacklist file
> #android.blacklist_src =
>
> # (list) List of Java .jar files to add to the libs so that pyjnius can access
> # their classes. Don't add jars that you do not need, since extra jars can slow
> # down the build process. Allows wildcards matching, for example:
> # OUYA-ODK/libs/*.jar
> #android.add_jars = foo.jar,bar.jar,path/to/more/*.jar
>
> # (list) List of Java files to add to the android project (can be java or a
> # directory containing the files)
> #android.add_src =
>
> # (list) Android AAR archives to add (currently works only with sdl2_gradle
> # bootstrap)
> #android.add_aars =
>
> # (list) Gradle dependencies to add (currently works only with sdl2_gradle
> # bootstrap)
> #android.gradle_dependencies =
>
>
> # (list) Android additional libraries to copy into libs/armeabi
> #android.add_libs_armeabi = libs/android/*.so
> #android.add_libs_armeabi_v7a = libs/android-v7/*.so
> #android.add_libs_arm64_v8a = libs/android-v8/*.so
> #android.add_libs_x86 = libs/android-x86/*.so
> #android.add_libs_mips = libs/android-mips/*.so
>
> # (bool) Indicate whether the screen should stay on
> # Don't forget to add the WAKE_LOCK permission if you set this to True
> #android.wakelock = False
>
> # (list) Android application meta-data to set (key=value format)
> #android.meta_data =
>
> # (list) Android library project to add (will be added in the
> # project.properties automatically.)
> #android.library_references =
>
> # (list) Android shared libraries which will be added to AndroidManifest.xml using <uses-library> tag
> #android.uses_library =
>
> # (str) Android logcat filters to use
> #android.logcat_filters = *:S python:D
>
> # (bool) Copy library instead of making a libpymodules.so
> #android.copy_libs = 1
>
> # (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64 android.arch = armeabi-v7a
>
> # (int) overrides automatic versionCode computation (used in build.gradle)
> # this is not the same as app version and should only be edited if you know what you're doing
> # android.numeric_version = 1
>
> #
> # Python for android (p4a) specific
> #
>
> # (str) python-for-android fork to use, defaults to upstream (kivy)
> #p4a.fork = kivy
>
> # (str) python-for-android branch to use, defaults to master
> #p4a.branch = master
>
> # (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
> #p4a.source_dir =
>
> # (str) The directory in which python-for-android should look for your own build recipes (if any)
> #p4a.local_recipes =
>
> # (str) Filename to the hook for p4a
> #p4a.hook =
>
> # (str) Bootstrap to use for android builds
> # p4a.bootstrap = sdl2
>
> # (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
> #p4a.port =
>
>
> #
> # iOS specific
> #
>
> # (str) Path to a custom kivy-ios folder
> #ios.kivy_ios_dir = ../kivy-ios
> # Alternately, specify the URL and branch of a git checkout: ios.kivy_ios_url = https://github.com/kivy/kivy-ios
> ios.kivy_ios_branch = master
>
> # Another platform dependency: ios-deploy
> # Uncomment to use a custom checkout
> #ios.ios_deploy_dir = ../ios_deploy
> # Or specify URL and branch ios.ios_deploy_url = https://github.com/phonegap/ios-deploy ios.ios_deploy_branch = 1.7.0
>
> # (str) Name of the certificate to use for signing the debug version
> # Get a list of available identities: buildozer ios list_identities
> #ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"
>
> # (str) Name of the certificate to use for signing the release version
> #ios.codesign.release = %(ios.codesign.debug)s
>
>
> [buildozer]
>
> # (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) log_level = 2
>
> # (int) Display warning if buildozer is run as root (0 = False, 1 = True) warn_on_root = 1
>
> # (str) Path to build artifact storage, absolute or relative to spec file
> # build_dir = ./.buildozer
>
> # (str) Path to build output (i.e. .apk, .ipa) storage
> # bin_dir = ./bin
>
> # -----------------------------------------------------------------------------
> # List as sections
> #
> # You can define all the "list" as [section:key].
> # Each line will be considered as a option to the list.
> # Let's take [app] / source.exclude_patterns.
> # Instead of doing:
> #
> #[app]
> #source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
> #
> # This can be translated into:
> #
> #[app:source.exclude_patterns]
> #license
> #data/audio/*.wav
> #data/images/original/*
> #
>
>
> # -----------------------------------------------------------------------------
> # Profiles
> #
> # You can extend section / key with a profile
> # For example, you want to deploy a demo version of your application without
> # HD content. You could first change the title to add "(demo)" in the name
> # and extend the excluded directories to remove the HD content.
> #
> #[app#demo]
> #title = My Application (demo)
> #
> #[app:source.exclude_patterns#demo]
> #images/hd/*
> #
> # Then, invoke the command line with the "demo" profile:
> #
> #buildozer --profile demo android debug
This is the log i get when i successfully ran my app in comand prompt(windows)
This is the log i get when i successfully ran my app in comand prompt(windows)

Okay. So that didn’t work for me what worked was adding kivy==2.0.0, kivymd==0.104.1

In your requirements line in your buildozer.spec file, use this
requirements = python3,kivy==2.0.0,https://github.com/kivymd/KivyMd/archive/master.zip,pygments,sdl2_ttf==2.0.15,pillow,docutils,plyer
This worked for me.

Related

How to be a properly configure Asia Unicode font and text display for FPDF2?

enter image description hereI am trying to generate PDF file with a Python library "FPDF2" with this method:
from fpdf import FPDF, XPos, YPos
import warnings
warnings.filterwarnings("ignore", message="Core font or font already added")
# PDF title
title = 'INVOICE#'
class PDF(FPDF):
def header(self):
# Add logo
# self.image("logo.png", 10, 10, 20)
# Set font style
self.set_font('helvetica', 'B', 18)
# Add Padding by calculated value of title
title_width = self.get_string_width(title) + 6
doc_width = self.w
self.set_x((doc_width - title_width) / 2)
# colors of frame, background, and text
self.set_draw_color(0, 80, 180) # blue
self.set_fill_color(230, 230, 0) # background color - Yellow
self.set_text_color(220, 50, 50) # text color - red
# Thickness of frame (border)
self.set_line_width(0.5)
# Title
self.cell(title_width, 10, title, new_y="NEXT", border = 1, align='C', fill=True)
# Line break
self.ln(10)
# Footer
def footer(self):
# Position cursor at 1.5 cm from bottom:
self.set_y(-15)
# Setting font: helvetica italic 8
self.set_font("helvetica", "I", 8)
self.set_text_color(169,169,169) # text color - gray
# Printing page number:
self.cell(0, 10, f"Design by Ezstartup Team. Page {self.page_no()}/{{nb}}", align="C")
# Create Chapter
def chapter_body(self, name):
with open(name, 'rb') as fh:
txt = fh.read().decode('utf-8')
# set font
self.add_font('KhmerOSBattambang', '', 'font/KhmerOSbattambang.ttf')
self.set_font('KhmerOSBattambang', size=14)
self.multi_cell(0, 10, txt)
pdf.ln()
# Create FPDF object
# Layout ('P', 'L')
# format ('A3', 'A4', (default), 'A5', 'Letter', 'Legal', (100, 150))
pdf = PDF(orientation="P", unit="mm", format="A4")
# Get total pages number
pdf.alias_nb_pages()
# Set margin
pdf.set_auto_page_break(auto=True, margin=15)
# Add a page
pdf.add_page()
# Display text
# Read the content of the file and decode it
pdf.chapter_body('chapter1.txt')
pdf.chapter_body('chapter2.txt')
# w = width, h = height
pdf.cell(40, 10, 'Hello World! សួស្តីលោកអ្នកនាង', chr(0x17DF), align='R') # position , align='R')
# PDF file
pdf.output('unicode.pdf')
But the result is not like what I expected.
I have attached the creation file. It's a problem with Khmer language. Please advise me to configure it and makes it working and displaying correctly.
I want to generate PDF file with FPDF2 with Khmer language (Unicode characters).

Kivy Buildozer returns me error while generating an .apk file. Python

I'm running 'buildozer android debug deploy run' command an it gives this error:
# Command failed: /home/kostinus/PycharmProjects/kivy_0.2/venv/bin/python -m pythonforandroid.toolchain create --dist_name=mykivy --bootstrap=sdl2 --requirements=python3,kivy --arch arm64-v8a --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/kostinus/PycharmProjects/kivy_0.2/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a" --ndk-api=21 --ignore-setup-py --debug
the full log:
# ENVIRONMENT:
# SHELL = '/bin/bash'
# SESSION_MANAGER = 'local/kostinus-K501LX:#/tmp/.ICE-unix/1965,unix/kostinus-K501LX:/tmp/.ICE-unix/1965'
# QT_ACCESSIBILITY = '1'
# SNAP_REVISION = '267'
# XDG_CONFIG_DIRS = '/etc/xdg/xdg-ubuntu:/etc/xdg'
# XDG_MENU_PREFIX = 'gnome-'
# GNOME_DESKTOP_SESSION_ID = 'this-is-deprecated'
# SNAP_REAL_HOME = '/home/kostinus'
# TERMINAL_EMULATOR = 'JetBrains-JediTerm'
# SNAP_USER_COMMON = '/home/kostinus/snap/pycharm-community/common'
# LC_ADDRESS = 'uk_UA.UTF-8'
# GNOME_SHELL_SESSION_MODE = 'ubuntu'
# LC_NAME = 'uk_UA.UTF-8'
# ...
# LC_TIME = 'uk_UA.UTF-8'
# SNAP_NAME = 'pycharm-community'
# JOURNAL_STREAM = '8:46911'
# XDG_DATA_DIRS = '/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop'
# PATH = '/home/kostinus/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/kostinus/PycharmProjects/kivy_0.2/venv/bin:/home/kostinus/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
# GDMSESSION = 'ubuntu'
# DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1000/bus'
# GIO_LAUNCHED_DESKTOP_FILE_PID = '13568'
# GIO_LAUNCHED_DESKTOP_FILE = '/var/lib/snapd/desktop/applications/pycharm-community_pycharm-community.desktop'
# LC_NUMERIC = 'uk_UA.UTF-8'
# _ = '/home/kostinus/PycharmProjects/kivy_0.2/venv/bin/buildozer'
# PACKAGES_PATH = '/home/kostinus/.buildozer/android/packages'
# ANDROIDSDK = '/home/kostinus/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/home/kostinus/.buildozer/android/platform/android-ndk-r19c'
# ANDROIDAPI = '27'
# ANDROIDMINAPI = '21'
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
All libraries are installed successfully.
OS - Ubuntu 20.04;
python -v == 3.8;
I ran Commands in PyCharm because in terminal it gives error of clonning git-repo.
Help, please.

YouCompleteMe :YcmDiag E788 can not edit another buffer now?

Why can not YCM edit its own buffer?
Diagnostics refreshed
Error detected while processing function <SNR>187_ShowDiagnostics:
line 1:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ubuntu/.vim/plugged/YouCompleteMe/python/ycm/youcompleteme.py", line 832, in ShowDiagnostics
vimsupport.OpenLocationList( focus = True )
File "/home/ubuntu/.vim/plugged/YouCompleteMe/python/ycm/vimsupport.py", line 385, in OpenLocationList
vim.command( 'lopen' )
vim.error: Vim(loadview):E788: Not allowed to edit another buffer now
My .ycm_extra_conf.py:
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wno-long-long',
'-Wno-variadic-macros',
'-DNDEBUG',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x', 'c',
'-I', '.',
'-I', './src/',
'-I', './include/',
'-I', './ClangCompleter',
'-isystem', '../llvm/include',
'-isystem', '../llvm/tools/clang/include',
'-isystem', './tests/gmock/gtest',
'-isystem', './tests/gmock/gtest/include',
'-isystem', './tests/gmock',
'-isystem', './tests/gmock/include',
'-isystem', '/usr/include',
'-isystem', '/usr/local/include',
'-isystem', './platform',
'-isystem', './platform/base',
'-isystem', './platform/base/RFCGeneral/',
'-isystem', './platform/base/RFCGeneral/event',
'-I', './platform',
'-I', './platform/base',
'-I', './platform/base/RFCGeneral/',
'-I', './platform/base/RFCGeneral/event',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile( replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}
The output of `:YcmDebuggInfo"
Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_iifk1o7e.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.8.10
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found and loaded
-- Extra configuration path: /home/ubuntu/workspace/proj/.ycm_extra_conf.py
-- C-family completer debug information:
-- Clangd running
-- Clangd process ID: 14913
-- Clangd executable: ['/home/ubuntu/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/clangd/output/bin/clangd', '-log=verbose', '-pretty', '-header-insertion-decorators=0', '-resource-dir=/home/ubuntu/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/13.0.0']
-- Clangd logfiles:
-- /tmp/clangd_stderr5hvc2xhc.log
-- Clangd Server State: Initialized
-- Clangd Project Directory: /home/ubuntu/workspace/roc_rsp_shell
-- Clangd Settings: {}
-- Clangd Compilation Command: False
-- Server running at: http://127.0.0.1:43927
-- Server process ID: 14873
-- Server logfiles:
-- /tmp/ycmd_43927_stdout_qts9v8rd.log
-- /tmp/ycmd_43927_stderr_saz7qf73.log
Press ENTER or type command to continue

Buildozer process failed executing the last command error while debugging for android

I have made a simple kivy app using also the socket module. But when I try to convert it to an android app using google collab and buildozer, I am getting this kind of an error.
{
ERROR: Could not find a version that satisfies the requirement socket (from versions: none)
ERROR: No matching distribution found for socket
STDERR:
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=starstocksapp --bootstrap=sdl2 --requirements=python3,socket,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/content/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
# ENVIRONMENT:
# CUDNN_VERSION = '8.0.5.39'
# PYDEVD_USE_FRAME_EVAL = 'NO'
# LD_LIBRARY_PATH = '/usr/local/nvidia/lib:/usr/local/nvidia/lib64'
# CLOUDSDK_PYTHON = 'python3'
# LANG = 'en_US.UTF-8'
# HOSTNAME = '047d4a118941'
# OLDPWD = '/'
# CLOUDSDK_CONFIG = '/content/.config'
# NVIDIA_VISIBLE_DEVICES = 'all'
# DATALAB_SETTINGS_OVERRIDES = '{"kernelManagerProxyPort":6000,"kernelManagerProxyHost":"172.28.0.3","jupyterArgs":["--ip=\\"172.28.0.2\\""],"debugAdapterMultiplexerPath":"/usr/local/bin/dap_multiplexer","enableLsp":true}'
# ENV = '/root/.bashrc'
# PAGER = 'cat'
# NCCL_VERSION = '2.7.8'
# TF_FORCE_GPU_ALLOW_GROWTH = 'true'
# JPY_PARENT_PID = '53'
# NO_GCE_CHECK = 'True'
# PWD = '/content'
# HOME = '/root'
# LAST_FORCED_REBUILD = '20211007'
# CLICOLOR = '1'
# DEBIAN_FRONTEND = 'noninteractive'
# LIBRARY_PATH = '/usr/local/cuda/lib64/stubs'
# GCE_METADATA_TIMEOUT = '0'
# GLIBCPP_FORCE_NEW = '1'
# TBE_CREDS_ADDR = '172.28.0.1:8008'
# TERM = 'xterm-color'
# SHELL = '/bin/bash'
# GCS_READ_CACHE_BLOCK_SIZE_MB = '16'
# PYTHONWARNINGS = 'ignore:::pip._internal.cli.base_command'
# MPLBACKEND = 'module://ipykernel.pylab.backend_inline'
# CUDA_VERSION = '11.1.1'
# NVIDIA_DRIVER_CAPABILITIES = 'compute,utility'
# SHLVL = '1'
# PYTHONPATH = '/env/python'
# NVIDIA_REQUIRE_CUDA = ('cuda>=11.1 brand=tesla,driver>=418,driver<419 '
'brand=tesla,driver>=440,driver<441 brand=tesla,driver>=450,driver<451')
# COLAB_GPU = '0'
# GLIBCXX_FORCE_NEW = '1'
# PATH = '/root/.buildozer/android/platform/apache-ant-1.9.4/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin:/opt/bin'
# LD_PRELOAD = '/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4'
# GIT_PAGER = 'cat'
# _ = '/usr/local/bin/buildozer'
# PACKAGES_PATH = '/root/.buildozer/android/packages'
# ANDROIDSDK = '/root/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/root/.buildozer/android/platform/android-ndk-r19c'
# ANDROIDAPI = '27'
# ANDROIDMINAPI = '21'
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
}
I don't know why this error keeps on coming. I have my main.py in the directory and I have checked to install all the modules. But still nothing happens.
I think socket module is not included or some problem is due to that I am including socket module. I have written the socket module's name in the spec file also in the modules to be included.
Thanks in Advance.
You don't have to add socket in requirements of your buildozer.spec file as they are inbuild modules in python. So, they will automatically get added when you add python3 in your requirements.
See this post for more info:
Buildozer not using correct kivy version when packaging for android

Getting table value from nowgoal has got an index error

I am quite new to scraping. I am getting links from nowgoal. Below is how I started navigating to above page. I do not wish to get link for all matches. But I will have an input text file, which is attached here and use the selected league and date.
The following code will initialize as input:
#Intialisation
league_index =[]
final_list = []
j = 0
#config load
config = RawConfigParser()
configFilePath = r'.\config.txt'
config.read(configFilePath)
date = config.get('database_config','date') #input file provided by user - provide in YYYY-MM-DD format
leagues = config.get('database_config','leagues') #input file provided by user - provide in windows format
headless_param =config.get('database_config','headless') #Headless param - set True if you want to see bowser operating in foreground!
leagues_list = leagues.split(',')
print(leagues_list)
After I initialized with the preferred date and league, I will set up for chrome driver as follow:
options = webdriver.ChromeOptions() #initialise webdriver options
#options.binary_location = brave_path #if you are running the script on brave - then enable it
if headless_param == 'True' :
print('headless')
options.headless = True # if headeless parameter is set to true - the chrome browser will not appear in foreground
options.add_argument('start-maximized') # Start the chrome maximised
options.add_argument('disable-infobars') # Disable infobars
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("prefs", {"profile.default_content_setting_values.cookies": 2})
options.add_experimental_option("prefs", {"profile.block_third_party_cookies": True})
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--incognito") #Incognito mode
#intiate the driver
driver = webdriver.Chrome(resource_path('./drivers/chromedriver.exe'),options=options)
#Format the url
url = 'http://www.nowgoal3.com/football/fixture/?f=ft0&date='+date
#get the url
driver.get(url)
#wait for some time
time.sleep(3)
driver.find_element_by_xpath('//*[#id="li_league"]').click()
time.sleep(5)
#click on the -team ranking
driver.find_element_by_xpath('//*[#id="TeamOrderCheck"]').click()
After this, you will be brought to the following page
I also add in the snap shot below
I try to get the data from the table by looping: the code is as follow:
> #Get the leagues name from page htmlSource = driver.page_source
> #Pass the htmlsource into soup soup = bs4.BeautifulSoup(htmlSource,'html.parser')
> #Table table = soup.select('table[id="table_live"]')
> #Rows of table all_rows = table[0].select('tr')
> #loop through each row
for i , row in enumerate(all_rows[2:]) :
> try:
> key_word = row['class'][0]
> print(key_word)
> if 'Leaguestitle' in key_word:#if leagues got changed
> league = row.a.text
> print(row.a.text)
> if row.a.text in leagues_list:
> j =1
> else:
> j =0
> elif j== 1:
> home_team = row.findAll('a')[0].text #home team
> print(home_team)
> away_team = row.findAll('a')[1].text #away team
> match_number = ''.join(filter(str.isdigit,row.findAll('a')[2]['href'].strip()))
> #match_number
> link = 'http://data.nowgoal.group/3in1odds/'+match_number+'.html'
> #link for 3 in 1 odds from the match code
> home_ranking = row.findAll('span')[0].text.strip('[]') #home team ranking
> away_ranking = row.findAll('span')[1].text.strip('[]') #Away team ranking
> final_list.append([home_team,home_ranking,away_team,away_ranking,league,match_number,link])
> except KeyError:
> try:
> if row['style']=='display:none':
> continue
> elif j== 1:
> home_team = row.findAll('a')[0].text #home team
> away_team = row.findAll('a')[1].text #away team
> home_ranking = row.findAll('span')[0].text.strip('[]') #home team ranking
> away_ranking = row.findAll('span')[1].text.strip('[]') #Away team ranking
> match_number = ''.join(filter(str.isdigit,row.findAll('a')[2]['href'].strip()))
> #match_code associated with each match
> link = 'http://data.nowgoal.group/3in1odds/'+match_number+'.html'
> #link for 3 in 1 odds from the match code
> final_list.append([home_team,home_ranking,away_team,away_ranking,league,match_number,link])
> except KeyError :
> print('KeyError')
>
>
> except IndexError:
> if j== 1:
> home_team = row.findAll('a')[0].text #home team
> away_team = row.findAll('a')[1].text #away team
> home_ranking = row.findAll('span')[0].text.strip('[]') #home team ranking
> away_ranking = row.findAll('span')[1].text.strip('[]') #Away team ranking
> match_number = ''.join(filter(str.isdigit,row.findAll('a')[2]['href'].strip()))
> #match_code associated with each match
> link = 'http://data.nowgoal.group/3in1odds/'+match_number+'.html'
> #link for 3 in 1 odds from the match code
> final_list.append([home_team,home_ranking,away_team,away_ranking,league,match_number,link])
> print('IndexError-captured')
>
> print(final_list)#show the final result driver.quit()#close the
> browser
Then I print out the hometeam and the following results
Chelsea adtext-bg QC: MAY88.COM - NHÀ CÁI HỢP PHÁP NA UY - THƯỞNG NẠP
100% - HOÀN TRẢ 100TR - HỖ TRỢ 24/7
Then it threw me an index error as follow:
Traceback (most recent call last):
File "D:/Football matters/Sttratagem data access/Games By Numbers/Nowgoal scraping project/codes/NOWGOAL-20200721T024808Z-001/NOWGOAL/PYFILES/Link_extractor_v1.3.py", line 124, in <module>
away_team = row.findAll('a')[1].text #away team
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Football matters/Sttratagem data access/Games By Numbers/Nowgoal scraping project/codes/NOWGOAL-20200721T024808Z-001/NOWGOAL/PYFILES/Link_extractor_v1.3.py", line 149, in <module>
away_team = row.findAll('a')[1].text #away team
IndexError: list index out of range
league_list = league_list = ["English Premier League", 'Italian Serie A',
'England Championship', 'Spanish La Liga', 'Swedish Allsvenskan', 'USA Major League Soccer','Saudi','Dutch Cup']
#wait for some time
# wait for some time
wait.until(EC.element_to_be_clickable((By.ID, "li_league"))).click()
# click on the -team ranking
wait.until(EC.element_to_be_clickable(
(By.XPATH, "//label[#for='TeamOrderCheck']/span"))).click()
for league in league_list:
try:
nextRow = wait.until(EC.presence_of_element_located(
(By.XPATH, '//tr[.//a[contains(text(),"{}")]]'.format(league))))
id = nextRow.get_attribute("id").split("_")[1]
try:
row = wait.until(EC.presence_of_all_elements_located(
(By.XPATH, '//tr[preceding-sibling::tr[.//a[contains(text(),"{}")]] and following-sibling::tr[#id="tr_{}"] and not(#style="display:none")]'.format(league, int(id)+1))))
print("########The result for {} ########".format(league))
for i in row:
print(i.get_attribute("textContent"))
print("###########Completed##############".format(league))
except:
row = wait.until(EC.presence_of_all_elements_located(
(By.XPATH, '//tr[preceding-sibling::tr[.//a[contains(text(),"{}")]] and not(#style="display:none")]'.format(league))))
print("########The result for {} ########".format(league))
for i in row:
print(i.get_attribute("textContent"))
print("###########Completed##############".format(league))
continue
except:
continue
you can use following and preceeding property , as there is no unique way to identify next following element we have to take id and increment it with 1
Prints all the information of each row.
wait = WebDriverWait(driver, 5)
driver.get('http://www.nowgoal3.com/football/fixture/?type=&f=sc1&date=2021-01-29')
league_list=["English Premier League",'Italian Serie A','England Championship','Spanish La Liga', 'Swedish Allsvenskan','USA Major League Soccer','Swiss Challenge League']
#wait for some time
wait.until(EC.element_to_be_clickable((By.ID, "li_league"))).click()
#click on the -team ranking
wait.until(EC.element_to_be_clickable((By.XPATH, "//label[#for='TeamOrderCheck']/span"))).click()
for league in league_list:
try:
header = driver.find_element_by_xpath("//tr[#class='Leaguestitle fbHead']/td[2]/span/a[text()='"+league+"']")
#print(len(header))
print(header.text)
nextRow = wait.until(EC.presence_of_element_located(
(By.XPATH, '//tr[.//a[contains(text(),"{}")]]'.format(league))))
id = nextRow.get_attribute("id").split("_")[1]
try:
rows = wait.until(EC.presence_of_all_elements_located(
(By.XPATH, '//tr[preceding-sibling::tr[.//a[contains(text(),"{}")]] and following-sibling::tr[#id="tr_{}"] and not(#style="display:none")]'.format(league, int(id)+1))))
except:
rows = wait.until(EC.presence_of_all_elements_located(
(By.XPATH, '//tr[preceding-sibling::tr[.//a[contains(text(),"{}")]] and not(#style="display:none")]'.format(league))))
continue
#print(len(rows))
for row in rows:
home = row.find_element_by_css_selector("td:nth-child(5) > a").text
homeRank = row.find_element_by_css_selector("td:nth-child(5) span.team-hg").text.strip('[]')
away = row.find_element_by_css_selector("td:nth-child(7) > a").text
awayRank = row.find_element_by_css_selector("td:nth-child(7) span.team-hg").text.strip('[]')
link = row.find_element_by_css_selector("td.toolimg >a:nth-child(3)").get_attribute('href')
link = ''.join(filter(lambda i: i.isdigit(), link))
link = 'http://data.nowgoal.group/3in1odds/'+link+'.html'
print(home,homeRank,away,awayRank,link)
except:
continue

Resources